shurcooL/graphql

Return more verbose error to the caller

rjjatson opened this issue · 1 comments

Hi,
There is currently no way to differentiate between various errors when doing a query/ mutation except from the error messages.

As error messages from the resource server are sometimes dubiety, some resource server does return error code on the extensionsfield so that the callers could identify the errors. Thus, I believe it would be very convenient if this package could provide a way to let the caller get the error's extensions value.

I am thinking something like what aws sdk does on their awserr. I would like to do something like this :

if err != nil {
    if gqlErr, ok := err.(graphql.Error); ok {
        // process error
        // if gqlErr.Code() == ...
    }
}

So im taking my chance to ask if there is any possibility that you could export the graphql.errors type and let the caller get whatever it is inside the extension? I could try to implement it if the idea sounds worth to do.
Or at least i would like to hear your opinion about handling various errors from the resource server.

Thanks !

#98
i believe having that one PR released would do the job.
wonder if any maintainers noticed it @dmitshur