graphql / graphql-spec

GraphQL is a query language and execution engine tied to any backend service.
https://spec.graphql.org
14.31k stars 1.13k forks source link

Relax non-inclusion of schema definition. #1047

Open ddebrunner opened 1 year ago

ddebrunner commented 1 year ago

"should" seems too strong here given a schema can have a description and directives applied to it.

linux-foundation-easycla[bot] commented 1 year ago

CLA Not Signed

netlify[bot] commented 1 year ago

Deploy Preview for graphql-spec-draft ready!

Name Link
Latest commit 6fc6d6388b2bd3dd3cf778801e86101baa7bd925
Latest deploy log https://app.netlify.com/sites/graphql-spec-draft/deploys/65142564607d86000882d4d6
Deploy Preview https://deploy-preview-1047--graphql-spec-draft.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

martinbonnin commented 1 year ago

One alternative would be to add more conditions to the "should"?

"Likewise, when representing a GraphQL schema using the type system definition language, a schema definition should be omitted if each root operation type uses its respective default root type name, no other type uses any default root type name and no schema directives are present."

I kind of like the "brevity by default" recommendation.

ddebrunner commented 1 year ago

and no description ...

benjie commented 1 year ago

We should keep the should for consistency - best that everyone generates the same SDL for the same schema where possible.

So I support @martinbonnin's proposal that we further narrow this case. I think the description was an oversight of https://github.com/graphql/graphql-spec/pull/466 - that's the main thing to include right now.

Note that there are no directives that would be visible on a schema keyword currently when the schema is printed (via introspection results) as SDL. The only directives currently included when representing a schema as SDL are @deprecated and @specifiedBy, though this may change when #300 is addressed. (This is not true for the source SDL, but that's not what we're talking about here.)