Skip to content
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

Schema Coordinates #3044

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Schema Coordinates #3044

wants to merge 1 commit into from

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 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
src/language/lexer.js Outdated Show resolved Hide resolved
Copy link

@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.

isDirective && '@',
name,
wrap('.', fieldName),
wrap('(', argumentName, ':)'),

Choose a reason for hiding this comment

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

:)

src/language/ast.js Outdated Show resolved Hide resolved
@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 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
src/language/ast.ts Outdated Show resolved Hide resolved
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`
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.

None yet

3 participants