-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Should _all_ GraphQL scalars be present in a schema? #222
Comments
I wonder if GraphQL lets you override the default scalars. I would guess "no" since they are used in introspection, which should be consistent across all servers? |
A Schema only needs to include the scalars that are present in a schema. However note that introspection is part of the schema, and the introspection system uses String and Boolean, so those are essentially always going to appear in every schema. |
And @stubailo, by the spec, as long as you have a type named |
Scalars can be omitted from a schema if they're never used. Likewise, scalars that are included must adhere to the spec. Added a paragraph clarifying this. Closes #222
Scalars can be omitted from a schema if they're never used. Likewise, scalars that are included must adhere to the spec. Added a paragraph clarifying this. Closes graphql#222
Let's say I'm working on my BCaaS app (bean counter as a service). My only inputs are
Int
s and my only return values areInt
s. Should my schema still contain GraphQL scalars likeString
andFloat
? Or is it appropriate to leave those types out, since they aren't used?It looks like graphql-js leaves out unused scalars. This approach makes sense to me. GraphQL's predefined scalars aren't "universals", instead, they're saving the user a step of defining their own. In that way, like an unused custom scalar, if a predefined scalar isn't used, it's not present in the schema.
Is that intended? Or should all GraphQL schemas contain the predefined scalar types?
The text was updated successfully, but these errors were encountered: