Skip to content

Commit 4de5ffd

Browse files
Update spec support for latest draft version (#342)
* Update spec support for latest draft version * Add .npmrc file to enforce nodejs version for export script * Small fix in export.sh script * Fix golangci error * Update .npmrc Add a little context to remind future us * Update readme.md * Update readme.md * Update main readme to point to the importer readme --------- Co-authored-by: Steve Coffman <[email protected]>
1 parent 217e304 commit 4de5ffd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1387
-420
lines changed

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ gqlparser [![CircleCI](https://badgen.net/circleci/github/vektah/gqlparser/maste
33

44
This is a parser for graphql, written to mirror the graphql-js reference implementation as closely while remaining idiomatic and easy to use.
55

6-
spec target: June 2018 (Schema definition language, block strings as descriptions, error paths & extension)
6+
spec target: [October 2021](https://spec.graphql.org/October2021/) and [select portions of the Draft](https://spec.graphql.org/draft/), based on the graphql-js reference implementation [graphql-js v16.10.0](https://github.com/graphql/graphql-js/releases/tag/v16.10.0). This includes Schema definition language, block strings as descriptions, error paths & extension, etc. If there is a spec update or [new release](https://github.com/graphql/graphql-spec/releases), please follow [this process to update](./validator/imported/readme.md) and submit a PR.
77

88
This parser is used by [gqlgen](https://github.com/99designs/gqlgen), and it should be reasonably stable.
99

validator/imported/.npmrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# .npmrc
2+
# engine-strict=true is so npm will stubbornly refuse
3+
# to install (or even consider installing) any package
4+
# that claims to not be compatible with the current Node.js version.
5+
engine-strict=true

validator/imported/export.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import fs from "fs";
22
import Module from "module";
33
import { testSchema } from "./graphql-js/src/validation/__tests__/harness";
4-
import { printSchema } from "./graphql-js/src/utilities";
4+
import { printSchema } from "./graphql-js/src";
55
import yaml from "js-yaml";
66

77
let schemas = [];

validator/imported/export.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ GIT_REF=origin/main
1010
if [[ -f "$EXPORTER_ROOT/graphql-js-commit.log" ]] ; then
1111
GIT_REF=$(cat "$EXPORTER_ROOT/graphql-js-commit.log")
1212
fi
13-
echo $GIT_REF
13+
echo "$GIT_REF"
1414

1515
if [[ -d "$REPO_DIR" ]] ; then
1616
echo "fetching graphql-js with ${GIT_REF}"
1717
cd "$REPO_DIR" || exit
18-
git fetch origin master
18+
git fetch origin main
1919
git checkout "$GIT_REF"
2020
git reset --hard
2121
else
@@ -24,7 +24,7 @@ else
2424
cd "$REPO_DIR" || exit
2525
git checkout "$GIT_REF"
2626
fi
27-
git rev-parse HEAD > $EXPORTER_ROOT/graphql-js-commit.log
27+
git rev-parse HEAD > "$EXPORTER_ROOT/graphql-js-commit.log"
2828

2929
cd "$EXPORTER_ROOT" || exit
3030

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
f597c694339b7c488f05496806e404659f6ff955
1+
48afd37a48d37f6d3342b959e8cb34e1ecbfeffb

validator/imported/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,8 @@
1515
},
1616
"devDependencies": {
1717
"prettier": "^3.4.2"
18+
},
19+
"engines": {
20+
"node": ">= 22"
1821
}
1922
}

validator/imported/readme.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
These specs have been generated from the testsuite in [graphql/graph-js](https://github.com/graphql/graphql-js).
44

5-
Direct modifications should not be made, instead take a look at the exporter.
5+
Direct modifications should not be made to most of this directory, instead take a look at the exporter.
66

77
```shell script
88
# update to latest
@@ -11,3 +11,7 @@ $ rm graphql-js-commit.log && ./export.sh
1111
# re-generate with known revision
1212
$ ./export.sh
1313
```
14+
15+
You will then need to manually update the [`validator/prelude.graphql`](./validator/prelude.graphql) file, [`validator/schema.go`](./validator/schema.go) file, and possibly other files relevant to those specific changes like [./validator/rules/](./validator/rules/), etc.
16+
17+
Please in your PR description note the git release tag that corresponds to the graphql-js commit.

validator/imported/spec/ExecutableDefinitionsRule.spec.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
name
99
}
1010
}
11-
11+
1212
errors: []
1313
- name: with operation and fragment
1414
rule: ExecutableDefinitions
@@ -25,7 +25,7 @@
2525
fragment Frag on Dog {
2626
name
2727
}
28-
28+
2929
errors: []
3030
- name: with type definition
3131
rule: ExecutableDefinitions
@@ -45,7 +45,7 @@
4545
extend type Dog {
4646
color: String
4747
}
48-
48+
4949
errors:
5050
- message: The "Cow" definition is not executable.
5151
locations:
@@ -67,7 +67,7 @@
6767
}
6868
6969
extend schema @directive
70-
70+
7171
errors:
7272
- message: The schema definition is not executable.
7373
locations:

validator/imported/spec/FieldsOnCorrectTypeRule.spec.yml

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
__typename
88
name
99
}
10-
10+
1111
errors: []
1212
- name: Aliased object field selection
1313
rule: FieldsOnCorrectType
@@ -18,7 +18,7 @@
1818
tn : __typename
1919
otherName : name
2020
}
21-
21+
2222
errors: []
2323
- name: Interface field selection
2424
rule: FieldsOnCorrectType
@@ -29,7 +29,7 @@
2929
__typename
3030
name
3131
}
32-
32+
3333
errors: []
3434
- name: Aliased interface field selection
3535
rule: FieldsOnCorrectType
@@ -39,7 +39,7 @@
3939
fragment interfaceFieldSelection on Pet {
4040
otherName : name
4141
}
42-
42+
4343
errors: []
4444
- name: Lying alias selection
4545
rule: FieldsOnCorrectType
@@ -49,7 +49,7 @@
4949
fragment lyingAliasSelection on Dog {
5050
name : nickname
5151
}
52-
52+
5353
errors: []
5454
- name: Ignores fields on unknown type
5555
rule: FieldsOnCorrectType
@@ -59,7 +59,7 @@
5959
fragment unknownSelection on UnknownType {
6060
unknownField
6161
}
62-
62+
6363
errors: []
6464
- name: reports errors when type is known again
6565
rule: FieldsOnCorrectType
@@ -73,7 +73,7 @@
7373
}
7474
}
7575
}
76-
76+
7777
errors:
7878
- message: Cannot query field "unknown_pet_field" on type "Pet".
7979
locations:
@@ -89,7 +89,7 @@
8989
fragment fieldNotDefined on Dog {
9090
meowVolume
9191
}
92-
92+
9393
errors:
9494
- message: Cannot query field "meowVolume" on type "Dog". Did you mean "barkVolume"?
9595
locations:
@@ -104,7 +104,7 @@
104104
deeper_unknown_field
105105
}
106106
}
107-
107+
108108
errors:
109109
- message: Cannot query field "unknown_field" on type "Dog".
110110
locations:
@@ -119,7 +119,7 @@
119119
unknown_field
120120
}
121121
}
122-
122+
123123
errors:
124124
- message: Cannot query field "unknown_field" on type "Pet".
125125
locations:
@@ -134,7 +134,7 @@
134134
meowVolume
135135
}
136136
}
137-
137+
138138
errors:
139139
- message: Cannot query field "meowVolume" on type "Dog". Did you mean "barkVolume"?
140140
locations:
@@ -147,7 +147,7 @@
147147
fragment aliasedFieldTargetNotDefined on Dog {
148148
volume : mooVolume
149149
}
150-
150+
151151
errors:
152152
- message: Cannot query field "mooVolume" on type "Dog". Did you mean "barkVolume"?
153153
locations:
@@ -160,7 +160,7 @@
160160
fragment aliasedLyingFieldTargetNotDefined on Dog {
161161
barkVolume : kawVolume
162162
}
163-
163+
164164
errors:
165165
- message: Cannot query field "kawVolume" on type "Dog". Did you mean "barkVolume"?
166166
locations:
@@ -173,7 +173,7 @@
173173
fragment notDefinedOnInterface on Pet {
174174
tailLength
175175
}
176-
176+
177177
errors:
178178
- message: Cannot query field "tailLength" on type "Pet".
179179
locations:
@@ -186,7 +186,7 @@
186186
fragment definedOnImplementorsButNotInterface on Pet {
187187
nickname
188188
}
189-
189+
190190
errors:
191191
- message: Cannot query field "nickname" on type "Pet". Did you mean to use an inline fragment on "Cat" or "Dog"?
192192
locations:
@@ -199,7 +199,7 @@
199199
fragment directFieldSelectionOnUnion on CatOrDog {
200200
__typename
201201
}
202-
202+
203203
errors: []
204204
- name: Direct field selection on union
205205
rule: FieldsOnCorrectType
@@ -209,7 +209,7 @@
209209
fragment directFieldSelectionOnUnion on CatOrDog {
210210
directField
211211
}
212-
212+
213213
errors:
214214
- message: Cannot query field "directField" on type "CatOrDog".
215215
locations:
@@ -222,7 +222,7 @@
222222
fragment definedOnImplementorsQueriedOnUnion on CatOrDog {
223223
name
224224
}
225-
225+
226226
errors:
227227
- message: Cannot query field "name" on type "CatOrDog". Did you mean to use an inline fragment on "Pet", "Cat", or "Dog"?
228228
locations:
@@ -240,5 +240,5 @@
240240
name
241241
}
242242
}
243-
243+
244244
errors: []

validator/imported/spec/FragmentsOnCompositeTypesRule.spec.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
fragment validFragment on Dog {
77
barks
88
}
9-
9+
1010
errors: []
1111
- name: interface is valid fragment type
1212
rule: FragmentsOnCompositeTypes
@@ -16,7 +16,7 @@
1616
fragment validFragment on Pet {
1717
name
1818
}
19-
19+
2020
errors: []
2121
- name: object is valid inline fragment type
2222
rule: FragmentsOnCompositeTypes
@@ -28,7 +28,7 @@
2828
barks
2929
}
3030
}
31-
31+
3232
errors: []
3333
- name: interface is valid inline fragment type
3434
rule: FragmentsOnCompositeTypes
@@ -40,7 +40,7 @@
4040
name
4141
}
4242
}
43-
43+
4444
errors: []
4545
- name: inline fragment without type is valid
4646
rule: FragmentsOnCompositeTypes
@@ -52,7 +52,7 @@
5252
name
5353
}
5454
}
55-
55+
5656
errors: []
5757
- name: union is valid fragment type
5858
rule: FragmentsOnCompositeTypes
@@ -62,7 +62,7 @@
6262
fragment validFragment on CatOrDog {
6363
__typename
6464
}
65-
65+
6666
errors: []
6767
- name: scalar is invalid fragment type
6868
rule: FragmentsOnCompositeTypes
@@ -72,7 +72,7 @@
7272
fragment scalarFragment on Boolean {
7373
bad
7474
}
75-
75+
7676
errors:
7777
- message: Fragment "scalarFragment" cannot condition on non composite type "Boolean".
7878
locations:
@@ -85,7 +85,7 @@
8585
fragment scalarFragment on FurColor {
8686
bad
8787
}
88-
88+
8989
errors:
9090
- message: Fragment "scalarFragment" cannot condition on non composite type "FurColor".
9191
locations:
@@ -98,7 +98,7 @@
9898
fragment inputFragment on ComplexInput {
9999
stringField
100100
}
101-
101+
102102
errors:
103103
- message: Fragment "inputFragment" cannot condition on non composite type "ComplexInput".
104104
locations:
@@ -113,7 +113,7 @@
113113
barks
114114
}
115115
}
116-
116+
117117
errors:
118118
- message: Fragment cannot condition on non composite type "String".
119119
locations:

0 commit comments

Comments
 (0)