Skip to content

Add Appendix C - Specified Type System Definitions #1037

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

martinbonnin
Copy link
Contributor

@martinbonnin martinbonnin commented Aug 5, 2023

As we dive into full schemas, introspection and more (see #1036), I'd find it useful to have an authoritative source for built-in definitions that come with a GraphQL implementation (scalar, directives & introspection types).

It shows the type system definitions at a glance and makes it easy to diff, capture a change by looking at the git history. It's also nice for library authors because it uniformizes the descriptions.

The definitions are taken from graphql-js printIntrospectionSchema() with two small changes:

  • I added the scalars definitions manually
  • I carried over the __Type.fields, __Type.interface, etc... descriptions from the current spec comments

I was doing this for my own needs so figured out I might as well contribute it to the spec but I'm happy to move it somewhere else if you think this doesn't belong in the spec.

@netlify
Copy link

netlify bot commented Aug 5, 2023

Deploy Preview for graphql-spec-draft ready!

Name Link
🔨 Latest commit d05591b
🔍 Latest deploy log https://app.netlify.com/projects/graphql-spec-draft/deploys/6841dd5b8a4b3300087d86e2
😎 Deploy Preview https://deploy-preview-1037--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 project configuration.

@martinbonnin
Copy link
Contributor Author

Would that qualify as an editorial change?

The validation/execution behaviour is essentially unchanged. The main thing that could be considered a behaviour change is that the definitions proposed here contain descriptions. We could either:

  • Remove descriptions
  • Add language that mandates the implementations use the same description as in the spec
  • Add language that the implementations are free to change the description if they want
  • Leave as is

benjie
benjie previously requested changes Sep 8, 2023
Copy link
Member

@benjie benjie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep this to just adding the appendix, it does not need to be referenced in the spec text (just as Appendix B is not referenced when grammar is mentioned).

@martinbonnin martinbonnin requested a review from benjie October 4, 2023 13:34
@benjie benjie dismissed their stale review October 4, 2023 14:23

Suggested changes were adopted.

@martinbonnin
Copy link
Contributor Author

martinbonnin commented Mar 6, 2025

I guess there's a distinction to be made between:

  1. implementations MUST always support it and expose the definition in introspection: @include, @defer, etc...
  2. implementations MAY support it but it may not always be present in introspection: @defer, @disableErrorPropagation, etc...

So I'm questioning wether built-in definitions is the proper term there. Maybe just specified definitions? Or just definitions? Thoughts?

Edit: I settled on "Type System Definitions"

Copy link
Contributor

@BoD BoD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a few dots and capital letters.

benjie
benjie previously requested changes Apr 3, 2025
Copy link
Member

@benjie benjie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reproduced your work by starting from a clean slate and then extracting the relevant definitions from the relevant sections; doing so revealed a few discrepancies that have crept in since you authored this:

Comment on lines 261 to 172
isRepeatable: Boolean!
locations: [__DirectiveLocation!]!
args(includeDeprecated: Boolean = false): [__InputValue!]!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's maintain the order of fields in the Introspection chapter

Suggested change
isRepeatable: Boolean!
locations: [__DirectiveLocation!]!
args(includeDeprecated: Boolean = false): [__InputValue!]!
locations: [__DirectiveLocation!]!
args(includeDeprecated: Boolean = false): [__InputValue!]!
isRepeatable: Boolean!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either we should re-order this in the spec, or in GraphQL-js. We should make it consistent.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@martinbonnin martinbonnin changed the title Add Appendix C - Built-in Definitions Add Appendix C - Type System Definitions Apr 3, 2025
Copy link
Member

@benjie benjie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's discuss whether or not we need this, or whether it should be re-incorporated back into the other chapters of the spec... But if agreed that a new appendix is warranted then I confirm the current state of it as accurate 👍

@benjie benjie dismissed their stale review April 3, 2025 11:50

Feedback addressed

@martinbonnin
Copy link
Contributor Author

Feedback from May wg:

  • Put everything in one giant block
  • Add a script to get the block from graphql-js (update graphql-js if some things are out of order)

Copy link
Member

@benjie benjie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM; couple minor suggestions.

Comment on lines 261 to 172
isRepeatable: Boolean!
locations: [__DirectiveLocation!]!
args(includeDeprecated: Boolean = false): [__InputValue!]!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either we should re-order this in the spec, or in GraphQL-js. We should make it consistent.

Comment on lines 10 to 11
This appendix lists all the type system definitions mentioned throughout this
specification.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not exactly true as there are plenty of examples written as type system definitions which we have not included. Perhaps:

Suggested change
This appendix lists all the type system definitions mentioned throughout this
specification.
This appendix lists the introspection types and builtin directives mentioned
throughout this specification.

Also... We're missing the builtin scalars? Might need to add those manually, or add a flag to printIntrospectionSchema to include them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're missing the builtin scalars?

Yikes, your're right. I think we want those in graphql-js. I'll look into it.

there are plenty of examples written as type system definitions which we have not included.

Right. What about just:

Suggested change
This appendix lists all the type system definitions mentioned throughout this
specification.
This appendix lists the built-in type system definitions.

?

Copy link
Contributor Author

@martinbonnin martinbonnin Jun 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, graphql-js has "specified scalars", which I think is exactly what we are looking for. I went with "specified type system definitions" in 275bf54, let me know how that looks.

@martinbonnin martinbonnin changed the title Add Appendix C - Type System Definitions Add Appendix C - Specified Type System Definitions Jun 5, 2025
martinbonnin added a commit to martinbonnin/graphql-js that referenced this pull request Jun 5, 2025
martinbonnin added a commit to martinbonnin/graphql-js that referenced this pull request Jun 5, 2025
enumValues(includeDeprecated: Boolean = false): [__EnumValue!]
inputFields(includeDeprecated: Boolean = false): [__InputValue!]
ofType: __Type
isOneOf: Boolean
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fun fact: I haven't found a version of GraphQL JS that matches the current draft:

  • 16.11.0 has @oneOf but draft doesn't
  • 16.8.0 doesn't have @oneOf but also doesn't have non-null includeDeprecated (which is in the draft)

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 this pull request may close these issues.

3 participants