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

ID type should be string not string | number #145

Closed
3 tasks done
benjie opened this issue Mar 20, 2024 · 2 comments · Fixed by #146
Closed
3 tasks done

ID type should be string not string | number #145

benjie opened this issue Mar 20, 2024 · 2 comments · Fixed by #146

Comments

@benjie
Copy link
Contributor

benjie commented Mar 20, 2024

Describe the bug

gql.tada specifies the default scalar ID as string | number:

interface DefaultScalars {
ID: number | string;

From the GraphQL Specification, 3.5.5 ID (emphasis mine):

The ID scalar type represents a unique identifier, often used to refetch an object or as the key for a cache. The ID type is serialized in the same way as a String; however, it is not intended to be human-readable. While it is often numeric, it should always serialize as a String.

I think this should should have been must, but the main point is an ID type should never come back from the server with typeof id === 'number', it will always be typeof id === 'string' (or null).

Reproduction

No response

gql.tada version

main branch

Validations

  • I can confirm that this is a bug report, and not a feature request, RFC, question, or discussion, for which GitHub Discussions should be used
  • Read the docs.
  • Follow our Code of Conduct
@JoviDeCroock
Copy link
Member

That's a good point, let's fix that!

@benjie
Copy link
Contributor Author

benjie commented Mar 20, 2024

I've raised an RFC PR to make this clearer: graphql/graphql-spec#1086

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants