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

Should _all_ GraphQL scalars be present in a schema? #222

Closed
rmosolgo opened this issue Oct 21, 2016 · 3 comments
Closed

Should _all_ GraphQL scalars be present in a schema? #222

rmosolgo opened this issue Oct 21, 2016 · 3 comments

Comments

@rmosolgo
Copy link

Let's say I'm working on my BCaaS app (bean counter as a service). My only inputs are Ints and my only return values are Ints. Should my schema still contain GraphQL scalars like String and Float? 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?

@stubailo
Copy link
Contributor

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?

@leebyron
Copy link
Collaborator

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.

@leebyron
Copy link
Collaborator

leebyron commented Oct 22, 2016

And @stubailo, by the spec, as long as you have a type named String (as an example) - it must conform to the spec's description of how String works. So that doesn't leave much room for overriding.

leebyron added a commit that referenced this issue Oct 28, 2016
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
IvanGoncharov pushed a commit to IvanGoncharov/graphql that referenced this issue Jun 17, 2017
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
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

No branches or pull requests

3 participants