Schema does not support operation type \"query\"
What happened?
Trying to use the embedded playground and I'm just getting 422 unprocessable entity:
{"errors":[{"message":"Schema does not support operation type \"query\"","locations":[{"line":2,"column":5}],"extensions":{"code":"GRAPHQL_VALIDATION_FAILED"}}],"data":null}
What did you expect?
Operation query to work.
Minimal graphql.schema and models to reproduce
https://github.com/Southclaws/storyden
Fire this up to reproduce, visit http://localhost:8000/graphql/ui for the graphiql interface that's failing.
The setup code for the graphql server is in app/transports/graphql/graphql.go
versions
-
github.com/99designs/gqlgen v0.17.16 - 1.19 latest
@Southclaws i guess its not able to resolve on path /query
do something like this in your server file
mux.Handle("/query", s) here
No, this is due to Query being not there in schema. Try adding dummy type Query in https://github.com/Southclaws/storyden/blob/main/api/thread.graphqls and you'll see the error getting vanished.
This seems to be a bug in schema validator as there can be schemas without Query type. FWIW, this error message originates from gqlparser package.
Ah this makes sense, thanks!
Please let's not close this before this get fixed or an appropriate issue is reported at relevant package. Why should there be a compulsion to have Query in the schema?
I'm making an atomic API with only some mutation, I would like to be able to have no query at all.
Late to the party - but this can also be due to your glqgen.yml file. I had to change/add these two parts:
federation:
filename: ./internal/gql/generated/federation.go
package: generated
model:
filename: ./internal/gql/gqlmodel/models_gen.go
package: gqlmodel