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

Add support for Apollo Connectors Mapping Syntax #230

Open
wants to merge 35 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
d0098ce
minimal changes to inject new grammar into directives
phryneas Oct 18, 2024
2637e5c
minimal (wrong) syntax highlighting for body & selection
phryneas Oct 18, 2024
1ae4203
body...
phryneas Oct 18, 2024
5e7f3dd
first attempt at jsonselection textmate grammar
phryneas Oct 18, 2024
839a650
injection not working yet
phryneas Oct 18, 2024
53c4a31
embed jsonselection as language
phryneas Oct 23, 2024
e4c6c87
some minor highlighting
phryneas Oct 23, 2024
60814f7
change to new ebnf, start over
phryneas Oct 24, 2024
c30aaf4
progress
phryneas Oct 24, 2024
bda40e6
progress
phryneas Oct 28, 2024
d0d2c77
getting somewhere
phryneas Oct 28, 2024
ab78a30
JSONSelectionString
phryneas Oct 28, 2024
e20832b
add comments, snapshot tests
phryneas Oct 28, 2024
b1ff896
update one grammar, move things
phryneas Oct 28, 2024
0ea12de
uncomment
phryneas Oct 28, 2024
5b85408
flip some priorities
phryneas Oct 29, 2024
51c573d
allow leading underscore in identifiers/keys/aliases
phryneas Oct 29, 2024
39c29d2
allow PUT|PATCH|DELETE
phryneas Oct 29, 2024
2a72811
split out connect-jsonselection-nested-argument, test
phryneas Oct 29, 2024
8711cf3
add schema ref
phryneas Oct 29, 2024
7c1fd89
fix: correct handling of nested objects
phryneas Oct 30, 2024
1483930
special highlighting for `({` `})` bracket pairs
phryneas Oct 30, 2024
073162f
fix typo
phryneas Oct 30, 2024
4deca72
highlighting of `@`, `$.` and `$.foo`
phryneas Oct 30, 2024
810cf1a
undo `{(` grouping
phryneas Oct 30, 2024
5c2ea2f
set apart `{` in `JSONSelectionString` visually
phryneas Oct 30, 2024
07b9f61
redo accidental wrong edit
phryneas Oct 30, 2024
f433e14
update snapshots, run more tests in CI
phryneas Oct 31, 2024
304b70c
also write graphql.connectors with a yaml source
phryneas Oct 31, 2024
5738e9a
rename scope according to recommendations
phryneas Oct 31, 2024
c84606b
rename things to "Apollo Connectors Mapping Syntax"
phryneas Oct 31, 2024
4280f23
sort the language at the end of the list
phryneas Oct 31, 2024
9c2ede1
reduce diff to original graphql grammar
phryneas Oct 31, 2024
ca52e1f
add comments to document injection logic
phryneas Oct 31, 2024
37f9377
Merge remote-tracking branch 'origin/main' into pr/textmate
phryneas Jan 7, 2025
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
7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,13 @@
"scopeName": "source.graphql",
"path": "./syntaxes/graphql.json"
},
{
"injectTo": [
"source.graphql"
],
"scopeName": "inline.connectors.graphql",
"path": "./syntaxes/graphql.connectors.json"
},
{
"injectTo": [
"source.js",
Expand Down
105 changes: 105 additions & 0 deletions syntaxes/graphql.connectors.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
{
"scopeName": "inline.connectors.graphql",
"injectionSelector": "L:meta.embedded.block.directive.graphql -string -comment",
"patterns": [{ "include": "#connect-directive" }],
"repository": {
"connect-directive": {
"begin": "((@)\\s*(connect))",
"end": "(?=.)",
"applyEndPatternLast": 1,
"beginCaptures": {
"1": {
"name": "entity.name.function.directive.connect.graphql"
}
},
"patterns": [
{ "include": "#connect-arguments" },
{ "include": "source.graphql#graphql-comment" },
{ "include": "source.graphql#literal-quasi-embedded" },
{ "include": "source.graphql#graphql-skip-newlines" }
]
},
"connect-arguments": {
"name": "meta.arguments.connect.graphql",
"begin": "\\s*(\\()",
"end": "\\s*(\\))",
"beginCaptures": {
"1": { "name": "meta.brace.round.directive.graphql" }
},
"endCaptures": {
"1": { "name": "meta.brace.round.directive.graphql" }
},
"patterns": [
{ "include": "source.graphql#graphql-comment" },
{ "include": "#connect-selection-argument" },
{ "include": "#connect-body-argument" },
{ "include": "source.graphql#graphql-argument" },
{ "include": "source.graphql#literal-quasi-embedded" }
]
},
"connect-selection-argument": {
"begin": "\\s*(selection)(?:\\s*(:))",
"end": "(?=\\s*(?:(?:([_A-Za-z][_0-9A-Za-z]*)\\s*(:))|\\)))|\\s*(,)",
"beginCaptures": {
"1": { "name": "variable.parameter.graphql" },
"2": { "name": "punctuation.colon.graphql" }
},
"endCaptures": {
"3": { "name": "punctuation.comma.graphql" }
},
"patterns": [
{
"begin": "\\s*+((\"))",
"end": "\\s*+(?:((\"))|(\n))",
"beginCaptures": {
"1": { "name": "string.quoted.double.graphql" },
"2": { "name": "punctuation.definition.string.begin.graphql" }
},
"endCaptures": {
"1": { "name": "string.quoted.double.graphql" },
"2": { "name": "punctuation.definition.string.end.graphql" },
"3": { "name": "invalid.illegal.newline.graphql" }
},
"patterns": [
{ "include": "source.graphql#graphql-field" },
{ "include": "source.graphql#graphql-comma" }
phryneas marked this conversation as resolved.
Show resolved Hide resolved
]
},
{ "include": "source.graphql#graphql-comment" },
{ "include": "source.graphql#graphql-skip-newlines" }
]
},
"connect-body-argument": {
"begin": "\\s*(selection)(?:\\s*(:))",
"end": "(?=\\s*(?:(?:([_A-Za-z][_0-9A-Za-z]*)\\s*(:))|\\)))|\\s*(,)",
"beginCaptures": {
"1": { "name": "variable.parameter.graphql" },
"2": { "name": "punctuation.colon.graphql" }
},
"endCaptures": {
"3": { "name": "punctuation.comma.graphql" }
},
"patterns": [
{
"begin": "\\s*+((\"))",
"end": "\\s*+(?:((\"))|(\n))",
"beginCaptures": {
"1": { "name": "string.quoted.double.graphql" },
"2": { "name": "punctuation.definition.string.begin.graphql" }
},
"endCaptures": {
"1": { "name": "string.quoted.double.graphql" },
"2": { "name": "punctuation.definition.string.end.graphql" },
"3": { "name": "invalid.illegal.newline.graphql" }
},
"patterns": [
{ "include": "source.graphql#graphql-field" },
{ "include": "source.graphql#graphql-comma" }
]
},
{ "include": "source.graphql#graphql-comment" },
{ "include": "source.graphql#graphql-skip-newlines" }
]
}
}
}
42 changes: 25 additions & 17 deletions syntaxes/graphql.json
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,14 @@
}
},
"graphql-directive": {
"begin": "\\s*((@)\\s*([_A-Za-z][_0-9A-Za-z]*))",
"contentName": "meta.embedded.block.directive.graphql",
"begin": "\\s*(?=@)",
"end": "(?=.)",
"applyEndPatternLast": 1,
"patterns": [{ "include": "#graphql-directive-body" }]
},
"graphql-directive-body": {
"begin": "((@)\\s*([_A-Za-z][_0-9A-Za-z]*))",
Comment on lines +345 to +352
Copy link
Member Author

Choose a reason for hiding this comment

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

I managed to get this down to a minimum amount of changes, but unfortunately not down to none.

"end": "(?=.)",
"applyEndPatternLast": 1,
"beginCaptures": {
Expand Down Expand Up @@ -442,25 +449,26 @@
},
"patterns": [
{ "include": "#graphql-comment" },
{
"begin": "\\s*([_A-Za-z][_0-9A-Za-z]*)(?:\\s*(:))",
"end": "(?=\\s*(?:(?:([_A-Za-z][_0-9A-Za-z]*)\\s*(:))|\\)))|\\s*(,)",
"beginCaptures": {
"1": { "name": "variable.parameter.graphql" },
"2": { "name": "punctuation.colon.graphql" }
},
"endCaptures": {
"3": { "name": "punctuation.comma.graphql" }
},
"patterns": [
{ "include": "#graphql-value" },
{ "include": "#graphql-comment" },
{ "include": "#graphql-skip-newlines" }
]
},
{ "include": "#graphql-argument" },
{ "include": "#literal-quasi-embedded" }
]
},
"graphql-argument": {
"begin": "\\s*([_A-Za-z][_0-9A-Za-z]*)(?:\\s*(:))",
"end": "(?=\\s*(?:(?:([_A-Za-z][_0-9A-Za-z]*)\\s*(:))|\\)))|\\s*(,)",
"beginCaptures": {
"1": { "name": "variable.parameter.graphql" },
"2": { "name": "punctuation.colon.graphql" }
},
"endCaptures": {
"3": { "name": "punctuation.comma.graphql" }
},
"patterns": [
{ "include": "#graphql-value" },
{ "include": "#graphql-comment" },
{ "include": "#graphql-skip-newlines" }
]
},
"graphql-variable-name": {
"match": "\\s*(\\$[_A-Za-z][_0-9A-Za-z]*)",
"captures": {
Expand Down
Loading