-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: log on unsuccessful responses #45
fix: log on unsuccessful responses #45
Conversation
lib/graphql-hive/client.rb
Outdated
def extract_error_details(response) | ||
parsed_body = JSON.parse(response.body) | ||
return unless parsed_body.is_a?(Hash) && parsed_body["errors"].is_a?(Array) | ||
parsed_body["errors"].map { |error| "path: #{error["path"]}, message: #{error["message"]}" }.join(", ") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"path" is the location of the error within the JSON structure of the request.
for example, if there is an error in the metadata: client
property, it will be
"path": "/operations/0/metadata/client"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great! Just wondering what the "error.message" looks like in the body? Just wondering if that is enough info to debug.
Knowing the field and reason would be huge though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Just a small nit about response.code
lib/graphql-hive/client.rb
Outdated
def extract_error_details(response) | ||
parsed_body = JSON.parse(response.body) | ||
return unless parsed_body.is_a?(Hash) && parsed_body["errors"].is_a?(Array) | ||
parsed_body["errors"].map { |error| "path: #{error["path"]}, message: #{error["message"]}" }.join(", ") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great! Just wondering what the "error.message" looks like in the body? Just wondering if that is enough info to debug.
Knowing the field and reason would be huge though.
Co-authored-by: Arya Bhimani <[email protected]>
Converted to draft, #46 first to fix bug in version 0.5.2 |
…raphql-ruby-hive into log-on-unsuccessful-responses
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for doing this. Can you please add tests for the logging you've added.
@rperryng this PR is ready to be merged! 🙏 |
Context
We want to add warning logs on client-level error responses.
Changes
>= 400 && < 500
.Testing
Added unit tests