Generating client produces "Undefined type String" error
Waitak opened this issue · 1 comments
Describe the bug
Running genqlient --init with this genqlient.graphql and this schema.graphql loaded from the Spire Maritime API using
% get-graphql-schema https://api.spire.com/graphql --sdl > api/schema.graphql
generates this error:
schema.graphql:107: invalid schema: Undefined type String.
exit status 1
To Reproduce
% go run github.com/Khan/genqlient --init
Expected behavior
I expected generated.go to be created.
genqlient version
v0.4.0
Additional context
Add any other context about the problem here.
Thanks for the report! The incorrect error is due to #175; in this case a better error is
/home/benkraft/src/genqlient/tmp/schema.graphql:4: invalid schema: Cannot redeclare directive specifiedBy.
The issue seems to be that get-graphql-schema
filters out most of the builtin GraphQL types and directives (so the schema isn't valid without including the "prelude" that defines String
, etc.) but not @specifiedBy
(which is also builtin, thus now defined twice). Ideally gqlparser would be a little more flexible in this case (the spec says built-in directives "may" be omitted but built-in types "must" be); I'll file an issue there. But in the meantime, the easiest thing for you is probably to simply remove that definition, and/or ask the get-graphql-schema
folks to filter it out.