Skip to content
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

expose details for returned errors #2

Merged
merged 1 commit into from
Feb 2, 2023

Conversation

setnicka
Copy link
Owner

@setnicka setnicka commented Feb 2, 2023

Copy of the original PR machinebox#48


Exposes the error as graphql.Error and returns error details in case they are present in the error response.

The user should assert the error type:

err := cli.Run(...)
if errs, ok := err.(graphql.Errors); ok {
  // Range over errs
}

// or with go 1.13
var errs graphql.Errors
if errors.As(err, errs) {
  // Range over errs
}

Included:

  • message: As before
  • locations: Locations in the query that caused errors
  • paths: Response paths that returned errors
  • extensions: Optional extensions set by the server. The spec specified it's a map but nothing more.

The format matches the June 2018 spec for errors: https://graphql.github.io/graphql-spec/June2018/#sec-Errors

This PR is very similar to some previous ones:

Exposes the error as graphql.Error and returns error details (path,
location, extensions) in case they are present in the error response.

The format matches the June 2018 spec for errors:
https://graphql.github.io/graphql-spec/June2018/#sec-Errors
@setnicka setnicka merged commit 7e9c542 into setnicka:master Feb 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants