Skip to content

Use :: syntax for enum values #1

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions spec/Appendix B -- Grammar Summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,15 @@ Token ::

Punctuator ::

- ColonPunctuator
- DotPunctuator
- OtherPunctuator

ColonPunctuator :: `:` [lookahead != {`:`}]

DotPunctuator :: `.` [lookahead != {`.`, Digit}]

OtherPunctuator :: one of ! $ & ( ) ... : = @ [ ] { | }
OtherPunctuator :: one of ! $ & ( ) ... :: = @ [ ] { | }

Name ::

Expand Down Expand Up @@ -423,17 +426,20 @@ TypeSystemDirectiveLocation : one of
SchemaCoordinate :

- TypeCoordinate
- MemberCoordinate
- FieldCoordinate
- ArgumentCoordinate
- ValueCoordinate
- DirectiveCoordinate
- DirectiveArgumentCoordinate

TypeCoordinate : Name

MemberCoordinate : Name . Name
FieldCoordinate : Name . Name

ArgumentCoordinate : Name . Name ( Name : )

ValueCoordinate : Name :: Name

DirectiveCoordinate : @ Name

DirectiveArgumentCoordinate : @ Name ( Name : )
8 changes: 7 additions & 1 deletion spec/Section 2 -- Language.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,17 +178,23 @@ and is {Ignored}.

Punctuator ::

- ColonPunctuator
- DotPunctuator
- OtherPunctuator

ColonPunctuator :: `:` [lookahead != {`:`}]

DotPunctuator :: `.` [lookahead != {`.`, Digit}]

OtherPunctuator :: one of ! $ & ( ) ... : = @ [ ] { | }
OtherPunctuator :: one of ! $ & ( ) ... :: = @ [ ] { | }

GraphQL documents include punctuation in order to describe structure. GraphQL is
a data description language and not a programming language, therefore GraphQL
lacks the punctuation often used to describe mathematical expressions.

The {`:`} punctuator must not be followed by a {`:`}. This ensures that the
source {"::"} can only be interpreted as a single {`::`} and not two {`:`}.

The {`.`} punctuator must not be followed by a {`.`} or {Digit}. This ensures
that the source {"..."} can only be interpreted as a single {`...`} and not
three {`.`}. It also avoids any potential ambiguity with {FloatValue}. As an
Expand Down
48 changes: 33 additions & 15 deletions spec/Section 3 -- Type System.md
Original file line number Diff line number Diff line change
Expand Up @@ -2174,17 +2174,20 @@ scalar UUID @specifiedBy(url: "https://tools.ietf.org/html/rfc4122")
SchemaCoordinate :

- TypeCoordinate
- MemberCoordinate
- FieldCoordinate
- ArgumentCoordinate
- ValueCoordinate
- DirectiveCoordinate
- DirectiveArgumentCoordinate

TypeCoordinate : Name

MemberCoordinate : Name . Name
FieldCoordinate : Name . Name

ArgumentCoordinate : Name . Name ( Name : )

ValueCoordinate : Name :: Name

DirectiveCoordinate : @ Name

DirectiveArgumentCoordinate : @ Name ( Name : )
Expand All @@ -2195,6 +2198,16 @@ _schema element_ within a GraphQL Schema.
:: A _schema element_ can be a named type, a field, an input field, an enum
value, a field argument, a directive, or a directive argument.

:: The _containing element_ of a _schema element_ is the schema element with one
fewer {Name} token that syntactically contains it. For example:

- The containing element of an {ArgumentCoordinate} or
{DirectiveArgumentCoordinate} is the corresponding {FieldCoordinate} or
{DirectiveCoordinate} respectively.
- The containing element of a {FieldCoordinate} or {ValueCoordinate} is its
containing {TypeCoordinate}.
- {TypeCoordinate} and {DirectiveCoordinate} have no containing element.

A _schema coordinate_ is always unique. Each _schema element_ can be referenced
by exactly one possible schema coordinate.

Expand All @@ -2220,31 +2233,27 @@ production.
To refer to a _schema element_, a _schema coordinate_ must be interpreted in the
context of a GraphQL {schema}.

If the _schema element_ cannot be found, the resolve function will not yield a
value (without raising an error). However, an error will be raised if any
non-leaf nodes within a _schema coordinate_ cannot be found in the {schema}.
If the _schema element_ cannot be found, and either it has no _containing
element_ or its _containing element_ exists and is of the expected type, the
resolve function returns {null}. Otherwise, an error is raised.

TypeCoordinate : Name

1. Let {typeName} be the value of {Name}.
2. Return the type in the {schema} named {typeName}, or {null} if no such type
exists.

MemberCoordinate : Name . Name
FieldCoordinate : Name . Name

1. Let {typeName} be the value of the first {Name}.
2. Let {type} be the type in the {schema} named {typeName}.
3. Assert: {type} must exist, and must be an Enum, Input Object, Object or
Interface type.
4. If {type} is an Enum type:
1. Let {enumValueName} be the value of the second {Name}.
2. Return the enum value of {type} named {enumValueName}, or {null} if no
such value exists.
5. Otherwise, if {type} is an Input Object type:
3. Assert: {type} must exist, and must be an Input Object, Object or Interface
type.
4. If {type} is an Input Object type:
1. Let {inputFieldName} be the value of the second {Name}.
2. Return the input field of {type} named {inputFieldName}, or {null} if no
such input field exists.
6. Otherwise:
5. Otherwise:
1. Let {fieldName} be the value of the second {Name}.
2. Return the field of {type} named {fieldName}, or {null} if no such field
exists.
Expand All @@ -2261,6 +2270,15 @@ ArgumentCoordinate : Name . Name ( Name : )
8. Return the argument of {field} named {fieldArgumentName}, or {null} if no
such argument exists.

ValueCoordinate : Name :: Name

1. Let {typeName} be the value of the first {Name}.
2. Let {type} be the type in the {schema} named {typeName}.
3. Assert: {type} must exist, and must be an Enum type.
4. Let {enumValueName} be the value of the second {Name}.
5. Return the enum value of {type} named {enumValueName}, or {null} if no such
value exists.

DirectiveCoordinate : @ Name

1. Let {directiveName} be the value of {Name}.
Expand All @@ -2283,8 +2301,8 @@ DirectiveArgumentCoordinate : @ Name ( Name : )
| Named Type | `Business` | `Business` type |
| Field | `Business.name` | `name` field on the `Business` type |
| Input Field | `SearchCriteria.filter` | `filter` input field on the `SearchCriteria` input object type |
| Enum Value | `SearchFilter.OPEN_NOW` | `OPEN_NOW` value of the `SearchFilter` enum |
| Field Argument | `Query.searchBusiness(criteria:)` | `criteria` argument on the `searchBusiness` field on the `Query` type |
| Enum Value | `SearchFilter::OPEN_NOW` | `OPEN_NOW` value of the `SearchFilter` enum |
| Directive | `@private` | `@private` directive |
| Directive Argument | `@private(scope:)` | `scope` argument on the `@private` directive |

Expand Down