Skip to content

Conversation

@leebyron
Copy link
Contributor

@leebyron leebyron commented Apr 16, 2021

Depends on #3115

Implements graphql/graphql-spec#794

Adds:

  • DOT punctuator in lexer
  • Improvements to lexer errors around misuse of .
  • Minor improvement to parser core which simplified this addition
  • SchemaCoordinate node and isSchemaCoodinate() predicate
  • Support in print() and visit()
  • Added function parseSchemaCoordinate() since it is a parser entry point.
  • Added function resolveSchemaCoordinate() and resolveASTSchemeCoordinate() which implement the semantics (name mirrored from buildASTSchema) as well as the return type GraphQLSchemaElement

@leebyron leebyron requested a review from IvanGoncharov April 16, 2021 09:33
@leebyron leebyron force-pushed the schema-coordinates branch 2 times, most recently from c7b87e2 to 0a5630a Compare April 16, 2021 09:46
@IvanGoncharov IvanGoncharov added the spec RFC Implementation of a proposed change to the GraphQL specification label Apr 16, 2021
Copy link
Contributor

@magicmark magicmark left a comment

Choose a reason for hiding this comment

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

Amazing!

This is way beyond what I was hacking with. Hadn't even considered reusing the existing parser. (I was fiddling around with regexes...)

Thanks for putting this together - this makes a lot of sense.

@leebyron leebyron force-pushed the schema-coordinates branch from a4a8920 to 42f9072 Compare April 22, 2021 07:27
@leebyron
Copy link
Contributor Author

leebyron commented Apr 22, 2021

Great feedback - I think I've resolved both:

  • Replaced fieldName with memberName in the AST to ensure it's generalized between fields, input fields, and enum values. Those are all specific instances of the general pattern of "members of a set", which is pretty common terminology for this generalized dot access pattern.
  • Took both of your great suggestions for wrapping the return type of resolveSchemaCoordinate - the ResolvedSchemaElement type is now a union of wrappers. This had the added benefits of disambiguating between "field argument" and "directive argument" and including the coordinate context in the return value

@leebyron leebyron requested a review from IvanGoncharov April 22, 2021 16:58
@leebyron leebyron force-pushed the schema-coordinates branch from 42f9072 to 1399f7c Compare May 27, 2021 23:55
@leebyron leebyron changed the base branch from main to lexer-cleanup May 27, 2021 23:55
@leebyron leebyron added the PR: feature 🚀 requires increase of "minor" version number label May 27, 2021
@leebyron leebyron force-pushed the lexer-cleanup branch 2 times, most recently from 3451e3e to 2f893d6 Compare May 28, 2021 22:21
@leebyron leebyron force-pushed the schema-coordinates branch from 1399f7c to 3cec8c2 Compare May 28, 2021 22:31
@leebyron leebyron force-pushed the schema-coordinates branch from 3cec8c2 to e688f88 Compare May 30, 2021 06:30
Implements graphql/graphql-spec#794

Adds:

* DOT punctuator in lexer
* Improvements to lexer errors around misuse of `.`
* Minor improvement to parser core which simplified this addition
* `SchemaCoordinate` node and `isSchemaCoodinate()` predicate
* Support in `print()` and `visit()`
* Added function `parseSchemaCoordinate()` since it is a parser entry point.
* Added function `resolveSchemaCoordinate()` and `resolveASTSchemaCoordinate()` which implement the semantics (name mirrored from `buildASTSchema`) as well as the return type `ResolvedSchemaElement`
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 think this is essentially good to go except for the comments noted, and that I think we should explicitly forbid {Ignored} from schema coordinates.

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.

Excellent work everyone, especially @magicmark!

@leebyron leebyron merged commit ec9c063 into next Sep 1, 2025
29 checks passed
yaacovCR added a commit to yaacovCR/graphql-js that referenced this pull request Dec 16, 2025
[graphql#3049 rebased on
main](graphql#3049).

This is the last rebased PR from the original PR stack concluding with
graphql#3049.

* Rebased: graphql#3809 [Original: graphql#3092]
* Rebased: graphql#3810 [Original: graphql#3074]
* Rebased: graphql#3811 [Original: graphql#3077]
* Rebased: graphql#3812 [Original: graphql#3065]
* Rebased: graphql#3813 [Original: graphql#3086]
* Rebased: graphql#3814 (this PR) [Original: graphql#3049]

Update: graphql#3044 and graphql#3145 have been separated from this stack.

Changes from original PR:
1. `astFromValue()` is deprecated instead of being removed.

@leebyron comments from graphql#3049, the original PR:
> Implements
[graphql/graphql-spec#793](graphql/graphql-spec#793)
> 
> * BREAKING: Changes default values from being represented as an
assumed-coerced "internal input value" to a pre-coerced "external input
value" (See chart below).
> This allows programmatically provided default values to be represented
in the same domain as values sent to the service via variable values,
and allows it to have well defined methods for both transforming into a
printed GraphQL literal string for introspection / schema printing (via
`valueToLiteral()`) or coercing into an "internal input value" for use
at runtime (via `coerceInputValue()`)
> To support this change in value type, this PR adds two related
behavioral changes:
>   
> * Adds coercion of default values from external to internal at runtime
(within `coerceInputValue()`)
> * Removes `astFromValue()`, replacing it with `valueToLiteral()` for
use in introspection and schema printing. `astFromValue()` performed
unsafe "uncoercion" to convert an "Internal input value" directly to a
"GraphQL Literal AST", where `valueToLiteral()` performs a well defined
transform from "External input value" to "GraphQL Literal AST".
> * Adds validation of default values during schema validation.
> Since assumed-coerced "internal" values may not pass "external"
validation (for example, Enum values), an additional validation error
has been included which attempts to detect this case and report a
strategy for resolution.
> 
> Here's a broad overview of the intended end state:
> 
> ![GraphQL Value
Flow](https://user-images.githubusercontent.com/50130/118379946-51ac5300-b593-11eb-839f-c483ecfbc875.png)

---------

Co-authored-by: Lee Byron <[email protected]>
yaacovCR added a commit to yaacovCR/graphql-js that referenced this pull request Dec 16, 2025
…QLEnumValue (graphql#4288)

this extracts logic from graphql#3044 and graphql#3145 (later rebased as graphql#3807 and
[the full schema coordinate
RFC](graphql/graphql-spec#794)

This is a BREAKING CHANGE because these schema elements are now longer
plain objects and function differently in various scenarios, for example
with `String(<schemaElement>` `JSON.stringifu(<schemaElement>` and
`.toString()` and `.toJSON()`

---------

Co-authored-by: Jovi De Croock <[email protected]>
yaacovCR added a commit to yaacovCR/graphql-js that referenced this pull request Dec 16, 2025
[graphql#3049 rebased on
main](graphql#3049).

This is the last rebased PR from the original PR stack concluding with
graphql#3049.

* Rebased: graphql#3809 [Original: graphql#3092]
* Rebased: graphql#3810 [Original: graphql#3074]
* Rebased: graphql#3811 [Original: graphql#3077]
* Rebased: graphql#3812 [Original: graphql#3065]
* Rebased: graphql#3813 [Original: graphql#3086]
* Rebased: graphql#3814 (this PR) [Original: graphql#3049]

Update: graphql#3044 and graphql#3145 have been separated from this stack.

Changes from original PR:
1. `astFromValue()` is deprecated instead of being removed.

@leebyron comments from graphql#3049, the original PR:
> Implements
[graphql/graphql-spec#793](graphql/graphql-spec#793)
> 
> * BREAKING: Changes default values from being represented as an
assumed-coerced "internal input value" to a pre-coerced "external input
value" (See chart below).
> This allows programmatically provided default values to be represented
in the same domain as values sent to the service via variable values,
and allows it to have well defined methods for both transforming into a
printed GraphQL literal string for introspection / schema printing (via
`valueToLiteral()`) or coercing into an "internal input value" for use
at runtime (via `coerceInputValue()`)
> To support this change in value type, this PR adds two related
behavioral changes:
>   
> * Adds coercion of default values from external to internal at runtime
(within `coerceInputValue()`)
> * Removes `astFromValue()`, replacing it with `valueToLiteral()` for
use in introspection and schema printing. `astFromValue()` performed
unsafe "uncoercion" to convert an "Internal input value" directly to a
"GraphQL Literal AST", where `valueToLiteral()` performs a well defined
transform from "External input value" to "GraphQL Literal AST".
> * Adds validation of default values during schema validation.
> Since assumed-coerced "internal" values may not pass "external"
validation (for example, Enum values), an additional validation error
has been included which attempts to detect this case and report a
strategy for resolution.
> 
> Here's a broad overview of the intended end state:
> 
> ![GraphQL Value
Flow](https://user-images.githubusercontent.com/50130/118379946-51ac5300-b593-11eb-839f-c483ecfbc875.png)

---------

Co-authored-by: Lee Byron <[email protected]>
yaacovCR added a commit to yaacovCR/graphql-js that referenced this pull request Dec 16, 2025
…QLEnumValue (graphql#4288)

this extracts logic from graphql#3044 and graphql#3145 (later rebased as graphql#3807 and
[the full schema coordinate
RFC](graphql/graphql-spec#794)

This is a BREAKING CHANGE because these schema elements are now longer
plain objects and function differently in various scenarios, for example
with `String(<schemaElement>` `JSON.stringifu(<schemaElement>` and
`.toString()` and `.toJSON()`

---------

Co-authored-by: Jovi De Croock <[email protected]>
yaacovCR added a commit to yaacovCR/graphql-js that referenced this pull request Dec 16, 2025
[graphql#3049 rebased on
main](graphql#3049).

This is the last rebased PR from the original PR stack concluding with
graphql#3049.

* Rebased: graphql#3809 [Original: graphql#3092]
* Rebased: graphql#3810 [Original: graphql#3074]
* Rebased: graphql#3811 [Original: graphql#3077]
* Rebased: graphql#3812 [Original: graphql#3065]
* Rebased: graphql#3813 [Original: graphql#3086]
* Rebased: graphql#3814 (this PR) [Original: graphql#3049]

Update: graphql#3044 and graphql#3145 have been separated from this stack.

Changes from original PR:
1. `astFromValue()` is deprecated instead of being removed.

@leebyron comments from graphql#3049, the original PR:
> Implements
[graphql/graphql-spec#793](graphql/graphql-spec#793)
> 
> * BREAKING: Changes default values from being represented as an
assumed-coerced "internal input value" to a pre-coerced "external input
value" (See chart below).
> This allows programmatically provided default values to be represented
in the same domain as values sent to the service via variable values,
and allows it to have well defined methods for both transforming into a
printed GraphQL literal string for introspection / schema printing (via
`valueToLiteral()`) or coercing into an "internal input value" for use
at runtime (via `coerceInputValue()`)
> To support this change in value type, this PR adds two related
behavioral changes:
>   
> * Adds coercion of default values from external to internal at runtime
(within `coerceInputValue()`)
> * Removes `astFromValue()`, replacing it with `valueToLiteral()` for
use in introspection and schema printing. `astFromValue()` performed
unsafe "uncoercion" to convert an "Internal input value" directly to a
"GraphQL Literal AST", where `valueToLiteral()` performs a well defined
transform from "External input value" to "GraphQL Literal AST".
> * Adds validation of default values during schema validation.
> Since assumed-coerced "internal" values may not pass "external"
validation (for example, Enum values), an additional validation error
has been included which attempts to detect this case and report a
strategy for resolution.
> 
> Here's a broad overview of the intended end state:
> 
> ![GraphQL Value
Flow](https://user-images.githubusercontent.com/50130/118379946-51ac5300-b593-11eb-839f-c483ecfbc875.png)

---------

Co-authored-by: Lee Byron <[email protected]>
yaacovCR added a commit to yaacovCR/graphql-js that referenced this pull request Dec 16, 2025
…QLEnumValue (graphql#4288)

this extracts logic from graphql#3044 and graphql#3145 (later rebased as graphql#3807 and
[the full schema coordinate
RFC](graphql/graphql-spec#794)

This is a BREAKING CHANGE because these schema elements are now longer
plain objects and function differently in various scenarios, for example
with `String(<schemaElement>` `JSON.stringifu(<schemaElement>` and
`.toString()` and `.toJSON()`

---------

Co-authored-by: Jovi De Croock <[email protected]>
yaacovCR added a commit to yaacovCR/graphql-js that referenced this pull request Dec 16, 2025
[graphql#3049 rebased on
main](graphql#3049).

This is the last rebased PR from the original PR stack concluding with
graphql#3049.

* Rebased: graphql#3809 [Original: graphql#3092]
* Rebased: graphql#3810 [Original: graphql#3074]
* Rebased: graphql#3811 [Original: graphql#3077]
* Rebased: graphql#3812 [Original: graphql#3065]
* Rebased: graphql#3813 [Original: graphql#3086]
* Rebased: graphql#3814 (this PR) [Original: graphql#3049]

Update: graphql#3044 and graphql#3145 have been separated from this stack.

Changes from original PR:
1. `astFromValue()` is deprecated instead of being removed.

@leebyron comments from graphql#3049, the original PR:
> Implements
[graphql/graphql-spec#793](graphql/graphql-spec#793)
> 
> * BREAKING: Changes default values from being represented as an
assumed-coerced "internal input value" to a pre-coerced "external input
value" (See chart below).
> This allows programmatically provided default values to be represented
in the same domain as values sent to the service via variable values,
and allows it to have well defined methods for both transforming into a
printed GraphQL literal string for introspection / schema printing (via
`valueToLiteral()`) or coercing into an "internal input value" for use
at runtime (via `coerceInputValue()`)
> To support this change in value type, this PR adds two related
behavioral changes:
>   
> * Adds coercion of default values from external to internal at runtime
(within `coerceInputValue()`)
> * Removes `astFromValue()`, replacing it with `valueToLiteral()` for
use in introspection and schema printing. `astFromValue()` performed
unsafe "uncoercion" to convert an "Internal input value" directly to a
"GraphQL Literal AST", where `valueToLiteral()` performs a well defined
transform from "External input value" to "GraphQL Literal AST".
> * Adds validation of default values during schema validation.
> Since assumed-coerced "internal" values may not pass "external"
validation (for example, Enum values), an additional validation error
has been included which attempts to detect this case and report a
strategy for resolution.
> 
> Here's a broad overview of the intended end state:
> 
> ![GraphQL Value
Flow](https://user-images.githubusercontent.com/50130/118379946-51ac5300-b593-11eb-839f-c483ecfbc875.png)

---------

Co-authored-by: Lee Byron <[email protected]>
yaacovCR added a commit to yaacovCR/graphql-js that referenced this pull request Dec 16, 2025
…QLEnumValue (graphql#4288)

this extracts logic from graphql#3044 and graphql#3145 (later rebased as graphql#3807 and
[the full schema coordinate
RFC](graphql/graphql-spec#794)

This is a BREAKING CHANGE because these schema elements are now longer
plain objects and function differently in various scenarios, for example
with `String(<schemaElement>` `JSON.stringifu(<schemaElement>` and
`.toString()` and `.toJSON()`

---------

Co-authored-by: Jovi De Croock <[email protected]>
yaacovCR added a commit to yaacovCR/graphql-js that referenced this pull request Dec 17, 2025
The original schema coordinates PR on v17 (graphql#3044), since backported to 16.x.x, had non-specified support for schema coordinates for metafields.

Co-authored-by: Benjie Gillam <[email protected]>
Co-authored-by: Mark Larah <[email protected]>
Co-authored-by: Yaacov Rydzinski <[email protected]>
yaacovCR added a commit to yaacovCR/graphql-js that referenced this pull request Dec 17, 2025
[graphql#3049 rebased on
main](graphql#3049).

This is the last rebased PR from the original PR stack concluding with
graphql#3049.

* Rebased: graphql#3809 [Original: graphql#3092]
* Rebased: graphql#3810 [Original: graphql#3074]
* Rebased: graphql#3811 [Original: graphql#3077]
* Rebased: graphql#3812 [Original: graphql#3065]
* Rebased: graphql#3813 [Original: graphql#3086]
* Rebased: graphql#3814 (this PR) [Original: graphql#3049]

Update: graphql#3044 and graphql#3145 have been separated from this stack.

Changes from original PR:
1. `astFromValue()` is deprecated instead of being removed.

@leebyron comments from graphql#3049, the original PR:
> Implements
[graphql/graphql-spec#793](graphql/graphql-spec#793)
> 
> * BREAKING: Changes default values from being represented as an
assumed-coerced "internal input value" to a pre-coerced "external input
value" (See chart below).
> This allows programmatically provided default values to be represented
in the same domain as values sent to the service via variable values,
and allows it to have well defined methods for both transforming into a
printed GraphQL literal string for introspection / schema printing (via
`valueToLiteral()`) or coercing into an "internal input value" for use
at runtime (via `coerceInputValue()`)
> To support this change in value type, this PR adds two related
behavioral changes:
>   
> * Adds coercion of default values from external to internal at runtime
(within `coerceInputValue()`)
> * Removes `astFromValue()`, replacing it with `valueToLiteral()` for
use in introspection and schema printing. `astFromValue()` performed
unsafe "uncoercion" to convert an "Internal input value" directly to a
"GraphQL Literal AST", where `valueToLiteral()` performs a well defined
transform from "External input value" to "GraphQL Literal AST".
> * Adds validation of default values during schema validation.
> Since assumed-coerced "internal" values may not pass "external"
validation (for example, Enum values), an additional validation error
has been included which attempts to detect this case and report a
strategy for resolution.
> 
> Here's a broad overview of the intended end state:
> 
> ![GraphQL Value
Flow](https://user-images.githubusercontent.com/50130/118379946-51ac5300-b593-11eb-839f-c483ecfbc875.png)

---------

Co-authored-by: Lee Byron <[email protected]>
yaacovCR added a commit to yaacovCR/graphql-js that referenced this pull request Dec 17, 2025
…QLEnumValue (graphql#4288)

this extracts logic from graphql#3044 and graphql#3145 (later rebased as graphql#3807 and
[the full schema coordinate
RFC](graphql/graphql-spec#794)

This is a BREAKING CHANGE because these schema elements are now longer
plain objects and function differently in various scenarios, for example
with `String(<schemaElement>` `JSON.stringifu(<schemaElement>` and
`.toString()` and `.toJSON()`

---------

Co-authored-by: Jovi De Croock <[email protected]>
yaacovCR added a commit to yaacovCR/graphql-js that referenced this pull request Dec 17, 2025
The original schema coordinates PR on v17 (graphql#3044), since backported to 16.x.x, had non-specified support for schema coordinates for metafields.

Co-authored-by: Benjie Gillam <[email protected]>
Co-authored-by: Mark Larah <[email protected]>
Co-authored-by: Yaacov Rydzinski <[email protected]>
yaacovCR added a commit to yaacovCR/graphql-js that referenced this pull request Dec 17, 2025
[graphql#3049 rebased on
main](graphql#3049).

This is the last rebased PR from the original PR stack concluding with
graphql#3049.

* Rebased: graphql#3809 [Original: graphql#3092]
* Rebased: graphql#3810 [Original: graphql#3074]
* Rebased: graphql#3811 [Original: graphql#3077]
* Rebased: graphql#3812 [Original: graphql#3065]
* Rebased: graphql#3813 [Original: graphql#3086]
* Rebased: graphql#3814 (this PR) [Original: graphql#3049]

Update: graphql#3044 and graphql#3145 have been separated from this stack.

Changes from original PR:
1. `astFromValue()` is deprecated instead of being removed.

@leebyron comments from graphql#3049, the original PR:
> Implements
[graphql/graphql-spec#793](graphql/graphql-spec#793)
> 
> * BREAKING: Changes default values from being represented as an
assumed-coerced "internal input value" to a pre-coerced "external input
value" (See chart below).
> This allows programmatically provided default values to be represented
in the same domain as values sent to the service via variable values,
and allows it to have well defined methods for both transforming into a
printed GraphQL literal string for introspection / schema printing (via
`valueToLiteral()`) or coercing into an "internal input value" for use
at runtime (via `coerceInputValue()`)
> To support this change in value type, this PR adds two related
behavioral changes:
>   
> * Adds coercion of default values from external to internal at runtime
(within `coerceInputValue()`)
> * Removes `astFromValue()`, replacing it with `valueToLiteral()` for
use in introspection and schema printing. `astFromValue()` performed
unsafe "uncoercion" to convert an "Internal input value" directly to a
"GraphQL Literal AST", where `valueToLiteral()` performs a well defined
transform from "External input value" to "GraphQL Literal AST".
> * Adds validation of default values during schema validation.
> Since assumed-coerced "internal" values may not pass "external"
validation (for example, Enum values), an additional validation error
has been included which attempts to detect this case and report a
strategy for resolution.
> 
> Here's a broad overview of the intended end state:
> 
> ![GraphQL Value
Flow](https://user-images.githubusercontent.com/50130/118379946-51ac5300-b593-11eb-839f-c483ecfbc875.png)

---------

Co-authored-by: Lee Byron <[email protected]>
yaacovCR added a commit to yaacovCR/graphql-js that referenced this pull request Dec 17, 2025
…QLEnumValue (graphql#4288)

this extracts logic from graphql#3044 and graphql#3145 (later rebased as graphql#3807 and
[the full schema coordinate
RFC](graphql/graphql-spec#794)

This is a BREAKING CHANGE because these schema elements are now longer
plain objects and function differently in various scenarios, for example
with `String(<schemaElement>` `JSON.stringifu(<schemaElement>` and
`.toString()` and `.toJSON()`

---------

Co-authored-by: Jovi De Croock <[email protected]>
yaacovCR added a commit to yaacovCR/graphql-js that referenced this pull request Dec 17, 2025
The original schema coordinates PR on v17 (graphql#3044), since backported to 16.x.x, had non-specified support for schema coordinates for metafields.

Co-authored-by: Benjie Gillam <[email protected]>
Co-authored-by: Mark Larah <[email protected]>
Co-authored-by: Yaacov Rydzinski <[email protected]>
yaacovCR added a commit to yaacovCR/graphql-js that referenced this pull request Dec 18, 2025
The original schema coordinates PR on v17 (graphql#3044), since backported to 16.x.x, had non-specified support for schema coordinates for metafields.

Co-authored-by: Benjie Gillam <[email protected]>
Co-authored-by: Mark Larah <[email protected]>
Co-authored-by: Yaacov Rydzinski <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: feature 🚀 requires increase of "minor" version number spec RFC Implementation of a proposed change to the GraphQL specification

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants