GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [RFC] GraphQL Schema Definition Language (SDL) by leebyron · Pull Request #90 · graphql/graphql-spec

Conversation

@leebyron

@leebyron leebyron commented Sep 2, 2015 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator

This adds the type definition syntax to the GraphQL specification.

There are some remaining issues to solve:

  • Include reference in Execution chapter about non-executable GraphQL
  • Description is not yet represented
  • Deprecation is not yet represented
  • Directives are not yet represented
  • Top level Schema is not yet represented
  • Investigate impact on validation rules
  • Decide on any or many rules for type fields / enum values
  • Combine into type system chapter
  • Consider separating into two top level grammars
  • Solve ambiguity for extending interfaces (Add test case for failing parsing graphql-js#1166)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

gutenye, stubailo, paulosuzart, calebmer, IvanGoncharov, RomanHotsiy, 2fd, okbel, juangl, volkanunsal, and 47 more reacted with thumbs up emoji Restuta and PocketlawErik reacted with hooray emoji junosuarez, eladams, sebas5384, brunoguerra, hansott, SerafimArts, raderio, jamesdphillips, acjay, draconids, and 11 more reacted with heart emoji
All reactions
  • 👍 57 reactions
  • 🎉 2 reactions
  • ❤️ 21 reactions
@leebyron

leebyron commented Sep 2, 2015

Copy link
Copy Markdown
Collaborator Author

Proposal for schema:

schema {
  query: QueryType
  mutation: MutationType
}
SchemaDefinition : schema { OperationTypeDefinition+ }
OperationTypeDefinition : OperationType : NamedType
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@facebook-github-bot facebook-github-bot added the CLA Signed label Sep 2, 2015
dittos
dittos reviewed Sep 2, 2015
View reviewed changes
Comment thread spec/Appendix B -- Grammar Summary.md Outdated

@dittos dittos Sep 2, 2015

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

syntax for UnionMembers is missing in appendix

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@leebyron leebyron Sep 2, 2015

Copy link
Copy Markdown
Collaborator Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Good catch, fixed!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@leebyron
leebyron force-pushed the rfc-idl branch from 58d79ec to 2ff83c4 Compare September 2, 2015 04:38
@nuance

nuance commented Nov 2, 2015

Copy link
Copy Markdown

Should this also include directives? Something like:

DirectiveDefinition : directive Name ArgumentsDefinition?

This doesn't capture scope / validation rules, so perhaps it should include an 'on' clause?

DirectiveDefinition : directive Name ArgumentsDefinition? DirectiveScopes?
DirectiveScopes : on DirectiveScope+
DirectiveScope : field | fragment | operation

So include would be defined like:

directive include(if: Boolean!) on field, fragment
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@joshprice

joshprice commented Jan 21, 2016

Copy link
Copy Markdown

Is there any movement on this? This is a pretty compelling piece of the GraphQL puzzle and opens up the possibility of tooling around schema design and also allows the creation of a cross language test suite.

baer, hansott, and lswith reacted with heart emoji
All reactions
  • ❤️ 3 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nuance

nuance commented Jan 21, 2016

Copy link
Copy Markdown

I ended up implementing most of this grammar in a project I'm working on. Here's the relevant lines from a PEG grammar (just the type parsing stuff):

TypeDefinition <- ObjectTypeDefinition / InterfaceTypeDefinition / UnionTypeDefinition / ScalarTypeDefinition / EnumTypeDefinition / InputObjectTypeDefinition / TypeExtensionDefinition / DirectiveDefinition
ObjectTypeDefinition <- "type" _ Name _ ImplementsInterfaces? _ "{" __ (FieldDefinition __)* "}"
ImplementsInterfaces <- "implements" _ (Name _)+
FieldDefinition <- Name _ ArgumentsDefinition? _ ':' _ InputType
ArgumentsDefinition <- '(' _ ( InputValueDefinition _ )* ')'
InputValueDefinition <- Name _ ':' _ InputType _ DefaultValue?
InterfaceTypeDefinition <- "interface" _ Name _ '{' __ (FieldDefinition __)+ '}'
UnionTypeDefinition <- ("union" / "Union") _ Name _ "=" _ UnionMembers
UnionMembers <- NamedType _ ("|" _ NamedType _)*
ScalarTypeDefinition <- "scalar" _ Name
EnumTypeDefinition <- "enum" _ Name _ "{" __ (EnumValue __)+ __ "}"
InputTypeDefinition <- Name _ ':' _ InputType _ DefaultValue?
InputObjectTypeDefinition <- "input" _ Name _ "{" __ (InputTypeDefinition __)+ "}"
DirectiveDefinition <- "directive" _ Name _ "on" _ (Name _)+ ArgumentsDefinition?
TypeExtensionDefinition <- "extend" _ ObjectTypeDefinition

I think this is basically compatible with the language defined in this PR, with a few additions (directives).

Answering the questions @leebyron asked:

  • description and deprecation are both expressed via directives
  • not sure what top level schema means - we define a query root object like:
type QueryRoot{}

then extend it as needed (I'm assuming that's what you're referencing?)

extend type QueryRoot {
    __schema : __Schema!
    __type(name: String!) : __Type
}
  • It's not clear what validation would be required. We're doing a little to catch compliance with the relay extensions and handle some of our own extensions, but nothing that passes the grammar has brought up anything interesting.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@joshprice

joshprice commented Jan 23, 2016

Copy link
Copy Markdown
  • Got a concrete example for implementing metadata (description, isDeprecated, etc) using directives @nuance ?
  • Top level schema I think refers to being able to parse the schema itself which is fairly trivial, just needs to be spec'd fully, but it looks like your example could use existing primitives
schema {
  query: QueryType
  mutation: MutationType
}
  • You can't mix type defs and queries which is described in the spec already, but presumably not in the execution section yet
  • Schema validation would be somewhat different to query validation, but as you point out if it is parsable then it's probably right, not sure what semantics could be validated? Guidance on orphan/unreferenced types, circular references, for a start
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@joshprice

joshprice commented Jan 23, 2016

Copy link
Copy Markdown

For reference there are some concrete examples here: https://github.com/matthewmueller/graph.ql

Descriptions are assumed to be in comments immediately preceding the thing it's describing, assuming deprecation etc could be handled in a similar fashion with a specially formatted comment.

Another possibility for metadata might be type annotations starting with @:

@description Describes a person
type Person {
  @isDeprecated true
  field: Int
}
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@joshprice

joshprice commented Jan 25, 2016

Copy link
Copy Markdown

Thinking more about how this is done with directives, you could make something quite readable:

@metadata(description: "Describes a person")
type Person {
  @metadata(isDeprecated true)
  field: Int
}
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@joshprice

joshprice commented Feb 19, 2016

Copy link
Copy Markdown

Enums are also an issue, since values are not able to be supplied using the current syntax

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@leebyron leebyron mentioned this pull request Mar 21, 2016
Common DSL and file type for schema definitions? #149
Closed
@leebyron
leebyron force-pushed the rfc-idl branch from 2ff83c4 to 80701d3 Compare March 22, 2016 21:09
@leebyron

leebyron commented Mar 22, 2016

Copy link
Copy Markdown
Collaborator Author

Updated to rebase atop recent changes and includes syntax for defining directives based on graphql/graphql-js#318

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@leebyron
leebyron force-pushed the rfc-idl branch 2 times, most recently from df904d2 to ace9871 Compare March 22, 2016 22:14
@leebyron

leebyron commented Mar 22, 2016

Copy link
Copy Markdown
Collaborator Author

Updated to rebase, fixed some outdated language and added SchemaDefinition

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

leebyron added a commit to graphql/graphql-js that referenced this pull request Mar 22, 2016
@leebyron
Updating schema parser to more closely match current state of RFC
b0885a0
graphql/graphql-spec#90
@leebyron leebyron mentioned this pull request Mar 22, 2016
Updating schema parser to more closely match current state of RFC graphql/graphql-js#323
Merged
leebyron added a commit to graphql/graphql-js that referenced this pull request Mar 22, 2016
@leebyron
[RFC] Add Schema Definition to IDL.
8379e71
This implements the schema definition in the spec proposal in graphql/graphql-spec#90

Adjusts AST, parser, printer, visitor, but also changes the API of buildASTSchema to require a schema definition instead of passing the type names into the function.
This was referenced Mar 22, 2016
[RFC] Add Schema Definition to IDL. graphql/graphql-js#325
Merged
Algebraic interface types #48
Open
@leebyron leebyron mentioned this pull request Apr 7, 2016
Spec and Build client-side GraphQL parser. graphql/graphql-js#21
Closed
@leebyron leebyron mentioned this pull request May 5, 2016
RFC: Schema Language Directives graphql/graphql-js#376
Merged
OlegIlyenko
OlegIlyenko reviewed May 22, 2016
View reviewed changes
Comment thread spec/Section 2 -- Language.md Outdated

#### Object

ObjectTypeDefinition : type Name ImplementsInterfaces? { FieldDefinition+ }

@OlegIlyenko OlegIlyenko May 22, 2016

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

@leebyron I think I found a mismatch with the reference implementation. It uses any to parse the list of fields, but according to spec it should use many (one or more field definitions):

https://github.com/graphql/graphql-js/blob/master/src/language/parser.js#L765

Should ObjectTypeDefinition be defined like this?

ObjectTypeDefinition : type Name ImplementsInterfaces? { FieldDefinition* }

(it's the same with the InputObjectTypeDefinition)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@leebyron leebyron May 23, 2016

Copy link
Copy Markdown
Collaborator Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Thanks for the catch and close read. I'll take a closer look and figure out which is more appropriate, but I think you're probably right.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

OlegIlyenko reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@OlegIlyenko OlegIlyenko mentioned this pull request May 22, 2016
IDL (schema definition) syntax parsing and rendering sangria-graphql/sangria#62
Closed
3 tasks done
sogko added a commit to sogko/graphql that referenced this pull request May 30, 2016
@sogko
Updating schema parser to more closely match current state of RFC
d66b3f3
graphql/graphql-spec#90

Commit:
b0885a038ec0e654962d69fb910ac86659279579 [b0885a0]
Parents:
fdafe32724
Author:
Lee Byron <[email protected]>
Date:
23 March 2016 at 6:35:37 AM SGT
Commit Date:
23 March 2016 at 6:35:39 AM SGT
sogko added a commit to sogko/graphql that referenced this pull request May 30, 2016
@sogko
[RFC] Add Schema Definition to IDL.
e23ac77
This implements the schema definition in the spec proposal in graphql/graphql-spec#90

Adjusts AST, parser, printer, visitor, but also changes the API of buildASTSchema to require a schema definition instead of passing the type names into the function.

Commit:
8379e71f7011fe044574f4bdef2a761d18d6cf2c [8379e71]
Parents:
176076c8a6
Author:
Lee Byron <[email protected]>
Date:
23 March 2016 at 7:38:15 AM SGT
Labels:
HEAD
@sogko sogko mentioned this pull request Jun 13, 2016
Schema Definition sogko/graphql-schema-language-cheat-sheet#2
Closed
@joshprice joshprice mentioned this pull request Jun 17, 2016
Schema DSL graphql-elixir/graphql#15
Closed
@leebyron
leebyron force-pushed the rfc-idl branch from cc99cbd to 5552659 Compare February 8, 2018 20:46
@leebyron
Fix reference to UnionMemberTypes
27d59b7
@leebyron
leebyron merged commit 593dd2c into master Feb 8, 2018
@leebyron
leebyron deleted the rfc-idl branch February 8, 2018 21:43
@pranaygp pranaygp mentioned this pull request Feb 10, 2018
[relay-compiler] Compiler fails to parse .graphql with new comment syntax meta/relay#2251
Closed
@cjoudrey cjoudrey mentioned this pull request Feb 21, 2018
Separate multiple inherited interfaces with & rmosolgo/graphql-ruby#1304
Merged
@stubailo stubailo mentioned this pull request Feb 27, 2018
Abstraction for reusable schema @directive implementations. ardatan/graphql-tools#640
Merged
4 of 5 tasks
tonyghita added a commit to graph-gophers/graphql-go that referenced this pull request Mar 7, 2018
@tonyghita
Separate multiple inherited interfaces with &
2985a52
This replaces:

```graphql
type Foo implements Bar, Baz { field: Type }
```

With:

```graphql
type Foo implements Bar & Baz { field: Type }
```

This is more consistent with other trailing lists of values which
either have an explicit separator (union members) or are prefixed
with a sigil (directives). This avoids parse ambiguity in the
case of an omitted field set, illustrated by
[github.com/graphql/graphql-js#1166](graphql/graphql-js#1166).

For now, the old method of declaration remains valid.

References:
- graphql/graphql-js#1169
- graphql/graphql-spec#90
- graphql/graphql-spec@32b55ed
@IvanGoncharov IvanGoncharov mentioned this pull request Mar 7, 2018
Question: difference between comments and descriptions? #420
Closed
This was referenced Mar 9, 2018
upgrade to graphparser 0.7.0 jamesdphillips/heroku-buildpack-libgraphqlparser-prebuilt#1
Open
upgrade to graphparser 0.7.0 proof-archive/heroku-buildpack-libgraphqlparser-prebuilt#1
Closed
@jburghardt jburghardt mentioned this pull request Mar 28, 2018
Update docs on schema graphql-java/graphql-java#999
Merged
@ermik

ermik commented May 11, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

@leebyron why is the spec still dated October 2016 at http://facebook.github.io/graphql/?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@IvanGoncharov

IvanGoncharov commented May 11, 2018

Copy link
Copy Markdown
Member

@ermik Because it's the last official release.
You can find the draft of the next release (including SDL) here:
http://facebook.github.io/graphql/draft/

ermik and musexiaojita reacted with heart emoji
All reactions
  • ❤️ 2 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jimkyndemeyer jimkyndemeyer mentioned this pull request Jun 16, 2018
[v2] Main issue for tracking progress on the v2 branch JetBrains/js-graphql-intellij-plugin#164
Closed
@danielkcz danielkcz mentioned this pull request Jul 4, 2018
Triple quote comments in schema break syntax highlighting kumarharsh/graphql-for-vscode#105
Closed
@Matt-Kantor-CK Matt-Kantor-CK mentioned this pull request Jul 4, 2018
Introspection fails when types implement multiple interfaces apollographql/apollo-tooling#434
Closed
@swolchok swolchok mentioned this pull request Sep 19, 2018
Schema parser doesn't handle "&" when specifying multiple interfaces graphql/libgraphqlparser#70
Open
tinnywang pushed a commit to tinnywang/graphql-go that referenced this pull request Dec 13, 2018
@tonyghita
Separate multiple inherited interfaces with &
9cbe07c
This replaces:

```graphql
type Foo implements Bar, Baz { field: Type }
```

With:

```graphql
type Foo implements Bar & Baz { field: Type }
```

This is more consistent with other trailing lists of values which
either have an explicit separator (union members) or are prefixed
with a sigil (directives). This avoids parse ambiguity in the
case of an omitted field set, illustrated by
[github.com/graphql/graphql-js#1166](graphql/graphql-js#1166).

For now, the old method of declaration remains valid.

References:
- graphql/graphql-js#1169
- graphql/graphql-spec#90
- graphql/graphql-spec@32b55ed
@brendanfalkowski brendanfalkowski mentioned this pull request Jan 19, 2019
Support for string literal comments rmosolgo/language-graphql#21
Open
@danielrearden danielrearden mentioned this pull request May 9, 2019
Add utility function function for generating fully-featured schema from SDL graphql/graphql-js#1858
Open
@IvanGoncharov IvanGoncharov mentioned this pull request Jul 23, 2019
State greediness of GraphQL #564
Closed
@IvanGoncharov IvanGoncharov mentioned this pull request Oct 8, 2019
Mark EnumValuesDefinition as required in EnumTypeDefinition #624
Closed
@renovate renovate Bot mentioned this pull request May 29, 2021
fix(deps): update dependency graphql to v0.13.2 PodShows/podcloud-feeds#83
Open
1 task
This was referenced Jun 6, 2021
Update dependency graphql to ^0.13.0 boxp/arks-gallery#4
Open
Update dependency graphql to >= 0.10.0 < 0.13.3 devinit/graphql-next#67
Open
chore(deps): update dependency @types/graphql to v0.13.4 graphql-cli/graphql-cli-voyager#16
Open
chore(deps): update dependency @types/graphql to v14 graphql-cli/graphql-cli-voyager#27
Open
mattstern31 pushed a commit to mattstern31/graphql-gqllero-repository that referenced this pull request Nov 10, 2022
Brian Thompson
Updating schema parser to more closely match current state of RFC
889ff24
graphql/graphql-spec#90

Commit:
b0885a038ec0e654962d69fb910ac86659279579 [b0885a0]
Parents:
fdafe32724
Author:
Lee Byron <[email protected]>
Date:
23 March 2016 at 6:35:37 AM SGT
Commit Date:
23 March 2016 at 6:35:39 AM SGT
mattstern31 pushed a commit to mattstern31/graphql-gqllero-repository that referenced this pull request Nov 10, 2022
Brian Thompson
[RFC] Add Schema Definition to IDL.
d7b8ab9
This implements the schema definition in the spec proposal in graphql/graphql-spec#90

Adjusts AST, parser, printer, visitor, but also changes the API of buildASTSchema to require a schema definition instead of passing the type names into the function.

Commit:
8379e71f7011fe044574f4bdef2a761d18d6cf2c [8379e71]
Parents:
176076c8a6
Author:
Lee Byron <[email protected]>
Date:
23 March 2016 at 7:38:15 AM SGT
Labels:
HEAD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@IvanGoncharov IvanGoncharov IvanGoncharov left review comments
+13 more reviewers
@kassens kassens kassens left review comments
@swolchok swolchok swolchok left review comments
@gjtorikian gjtorikian gjtorikian left review comments
@OlegIlyenko OlegIlyenko OlegIlyenko left review comments
@stubailo stubailo stubailo left review comments
@JeffRMoore JeffRMoore JeffRMoore left review comments
@acjay acjay acjay left review comments
@bbakerman bbakerman bbakerman left review comments
@vergenzt vergenzt vergenzt left review comments
@SerafimArts SerafimArts SerafimArts left review comments
@mohawk2 mohawk2 mohawk2 left review comments
@JonasTaulien JonasTaulien JonasTaulien left review comments
@RumataEstor RumataEstor RumataEstor requested changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

20 participants

@leebyron @nuance @joshprice @charlieschwabacher @helfer @OlegIlyenko @exogen @sergehuber @stubailo @tendant @domkm @luolong @emilebosch @sbussard @IvanGoncharov @pksunkara @foomip @gjtorikian @andimarek @SerafimArts
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.