Skip to content
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

Cannot redeclare type ID #224

Open
nickwesselman opened this issue Sep 6, 2022 · 1 comment
Open

Cannot redeclare type ID #224

nickwesselman opened this issue Sep 6, 2022 · 1 comment
Labels
bug Something isn't working
Milestone

Comments

@nickwesselman
Copy link

Describe the bug
Our schema at Shopify includes a redeclaration of the ID type, with an updated description documentation on its expected format for our endpoints. This is valid schema, but attempting to generate using it results in the following error:

go run github.com/Khan/genqlient
prelude.graphql:16: invalid schema: Cannot redeclare type ID.
exit status 1

To Reproduce
Create and use a schema with a custom ID type, e.g.

"""
Represents a unique identifier that is Base64 obfuscated. It is often used to
refetch an object or as key for a cache. The ID type appears in a JSON response
as a String; however, it is not intended to be human-readable. When expected as
an input type, any string (such as `"VXNlci0xMA=="`) or integer (such as `4`)
input value will be accepted as an ID.
"""
scalar ID

Expected behavior
The duplicated scalar is not treated as an error.

genqlient version
v0.5.0

@nickwesselman nickwesselman added the bug Something isn't working label Sep 6, 2022
@benjaminjkraft
Copy link
Collaborator

Ugh, the vagueness of the spec's language about schema validation bites us again :( . I feel gqlparser made better decisions here (by saying you don't get to redefine anything, even builtins), but sadly where the spec is vague we probably just have to match what graphql-js does since that's the de-facto standard.

So I think we will need to go the same route we did with directives in vektah/gqlparser#226, and have the parser allow repeated builtin types (scalars and introspection types) just as it now allows repeated builtin directives. CC @StevenACoffman in case you have any thoughts; in theory we could also fix this up in genqlient but it seems kinda silly. (We'll also need to update the stuff from #205; maybe we can just remove it actually, which would be great.)

@benjaminjkraft benjaminjkraft added this to the v1.0 milestone Jan 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants