Skip to content

error response #74

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

Closed
bsr203 opened this issue Nov 14, 2015 · 2 comments
Closed

error response #74

bsr203 opened this issue Nov 14, 2015 · 2 comments

Comments

@bsr203
Copy link

bsr203 commented Nov 14, 2015

As per the spec, https://facebook.github.io/graphql/#sec-Errors , error is indicated by a field errors of non empty list in the response.

so I was returning something like from my field resolver

return &graphql.Result{Errors: gqlerrors.FormatErrors(err)}

but that didn't work.

it does further validation and output the message

Locations: [{Line: 1, Column: 302}]
Message: "Cannot return null for non-nullable field GroupConnection.pageInfo."

my intention is to add more details to the error in the data field.

so, how can I return an error from Resolve method which passes to the client?

@sogko
Copy link
Member

sogko commented Nov 18, 2015

Currently there isn't a way to return a custom error from field resolvers.

This is being considered in #44, i.e. to allow user to return an error from Resolve function) #44 (comment)

For e.g.:

    helloResolve := func(p graphql.ResolveParams) (interface{}, error) {
        ...
        if err != nil {
            return nil, err
        }
        return "world", nil
    }

You're welcome to add to the discussion there to keep it going 👍🏻 (PRs are also welcomed :))

@bsr203
Copy link
Author

bsr203 commented Nov 24, 2015

closing so we track it at #44

@bsr203 bsr203 closed this as completed Nov 24, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants