graphql-go / graphql

An implementation of GraphQL for Go / Golang
MIT License
9.87k stars 839 forks source link

Won't return errors correctly with graphql.Do/graphql.Params #584

Closed dakaii closed 2 years ago

dakaii commented 3 years ago

I initially wired up my GraphQL handler with gorilla mux, thinking that it should return errors as shown in this article. https://ednsquare.com/story/go-graphql-handling-graphql-errors-4------dToD9I

But, it didn't work, and it seems like the errors are only correctly shown with the handler.Config method. https://github.com/gufranmirza/go-graphql-swapi/blob/master/go-greaphql-part-1/after/main.go

I wanted to use Context as shown in this example. https://github.com/graphql-go/graphql/blob/master/examples/context/main.go, but is there a way to return errors with graphql.Do method?

To summarize: graphq.Params doesn't have FormatErrorFn func(err error) gqlerrors.FormattedError as an argument, but is there a way to return readable errors with graphq.Params? I'm actually confused as to why there are two different ways to serve the schema. why is the GraphQL schema being served differently in the examples linked above?