Schema coordinates#4463
Conversation
My two cents on this is that we already have quite a bloated idea of a parser/lexer, in an ideal world we would split up the parser to be the Definition- and Execution Language. Which would help clients tree-shake down to a minimal Example:
This mostly to say that to push a spec forward I wouldn't really be bothered too much about the increase in bundle-size/lack of tree-shaking. For clients we are already massively overweight as we deliver SDL regardless of your needs. In the ideal world scenario the coordinates parser could be tied to the SDL lexer which would exempt clients from importing this by default. |
|
@leebyron I'm merging this into your PR as it follows your wishes (roughly) - do feel free to edit as you see fit! |
this was (afaict) correctly done in the backport of schema coordinates to 16.x.x (graphql#4463) but incorrect on next (graphql#3044)
this was (afaict) correctly done in the backport of schema coordinates to 16.x.x (graphql#4463) but incorrect on next (graphql#3044)
@benjie @leebyron This PR implements the changes on top of the existing
schema-coordinatesbranch as discussed in July's WG meeting:https://github.com/graphql/graphql-wg/blob/main/notes/2025/2025-07.md#schema-coordinates
Specifically:
SchemaCoordinateLexerclass insidesrc/language/schemaCoordinateLexer{createToken, printCodePointAt, readName}helpersLexerInterfaceinterface to allow the helpers to accept either instance of a Lexer without copy/pasting.What I dislike about this PR:
LexerInterface)What I like about this PR:
tl;dr if we tried to completely devolve
Parserof responsibility of schema coordinates, and started on a minimal implementation ofparseSchemaCoordinate()that advances a lexer instance token by token, we'd end up at something very similar to Parser.... I did try a few versions of this and copy and pasting things but this ended up being neater overall.FWIW I did start to a attempt a minimal
parseSchemaCoordinate()function here: https://github.com/magicmark/graphql-js/blob/586b7174dc730fef47368ce4fbc385fb1f733360/src/language/schemaCoordinate.ts#L44but it turns out that doing it imperatively and correctly without a nice lexer/parser is kinda hard! the more logic I add to this, the closer I get to essentially recreating a lexer/parser... which we already have :)
wdyt? should we keep trying for more of a middle ground here?