Skip to content

Commit b5206e8

Browse files
Adjust export.sh script and commit to graphql-js v16.13.2
Signed-off-by: Steve Coffman <steve@khanacademy.org>
1 parent 25b5c21 commit b5206e8

7 files changed

Lines changed: 42 additions & 18 deletions

File tree

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: [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.
6+
spec target: [September 2025](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.13.2](https://github.com/graphql/graphql-js/releases/tag/v16.13.2). 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/export.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,10 @@ function exportSpecDefinitions() {
131131
expectSDLValidationErrors(schema, rule, sdlStr) {
132132
return resultProxy("expectSDLValidationErrors", {
133133
toDeepEqual(expected) {
134-
// ignore now...
134+
// ignore now... pluggable named-rule system here is for
135+
// query/operation validation only.
136+
// SDL Validation happens imperatively in ValidateSchemaDocument in
137+
// schema.go, at schema load time so error messages will diverge.
135138
// console.warn(rule.name, sdlStr, JSON.stringify(expected, null, 2));
136139
},
137140
});
@@ -209,7 +212,7 @@ function exportSpecDefinitions() {
209212
let schemaList = schemas.map((s) => printSchema(s));
210213

211214
schemaList[0] += `
212-
# injected becuase upstream spec is missing some types
215+
# injected because upstream spec is missing some types
213216
extend type QueryRoot {
214217
field: T
215218
f1: Type

validator/imported/export.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ REPO_DIR=./graphql-js
44
EXPORTER_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
55

66
cd "$EXPORTER_ROOT" || exit
7-
8-
GIT_REF=origin/main
7+
# graphql-js default branch is not main anymore
8+
MAIN="16.x.x"
9+
GIT_REF="origin/${MAIN}"
910

1011
if [[ -f "$EXPORTER_ROOT/graphql-js-commit.log" ]] ; then
1112
GIT_REF=$(cat "$EXPORTER_ROOT/graphql-js-commit.log")
@@ -15,7 +16,7 @@ echo "$GIT_REF"
1516
if [[ -d "$REPO_DIR" ]] ; then
1617
echo "fetching graphql-js with ${GIT_REF}"
1718
cd "$REPO_DIR" || exit
18-
git fetch origin main
19+
git fetch origin "${MAIN}"
1920
git checkout "$GIT_REF"
2021
git reset --hard
2122
else
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
e2457b33e928f4ec8b22e96a6dc6cb2808c03dfa
1+
123e958de1362eef098c30e917b51981c484729e

validator/imported/readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Direct modifications should not be made to most of this directory, instead take
88
# update to latest
99
$ rm graphql-js-commit.log && ./export.sh
1010

11-
# re-generate with known revision
11+
# re-generate with known revision set in graphql-js-commit.log
1212
$ ./export.sh
1313
```
1414

validator/rules/values_of_correct_type.go

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -153,16 +153,8 @@ func ruleFuncValuesOfCorrectType(observers *Events, addError AddErrFunc, disable
153153
return
154154
}
155155

156-
isVariable := fieldValue.Kind == ast.Variable
157-
if isVariable {
158-
variableName := fieldValue.VariableDefinition.Variable
159-
isNullableVariable := !fieldValue.VariableDefinition.Type.NonNull
160-
if isNullableVariable {
161-
addError(
162-
Message(`Variable "%s" must be non-nullable to be used for OneOf Input Object "%s".`, variableName, value.Definition.Name),
163-
At(fieldValue.Position),
164-
)
165-
}
156+
if fieldValue.Kind == ast.Variable {
157+
return
166158
}
167159
}()
168160
}

validator/rules/variables_in_allowed_position.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,33 @@ var VariablesInAllowedPositionRule = Rule{
4242
)
4343
}
4444
})
45+
46+
observers.OnValue(func(walker *Walker, value *ast.Value) {
47+
if value.Kind != ast.ObjectValue || value.Definition == nil {
48+
return
49+
}
50+
if value.Definition.Directives.ForName("oneOf") == nil {
51+
return
52+
}
53+
54+
for _, child := range value.Children {
55+
fieldValue := child.Value
56+
if fieldValue == nil || fieldValue.Kind != ast.Variable || fieldValue.VariableDefinition == nil {
57+
continue
58+
}
59+
if !fieldValue.VariableDefinition.Type.NonNull {
60+
addError(
61+
Message(
62+
`Variable "%s" is of type "%s" but must be non-nullable to be used for OneOf Input Object "%s".`,
63+
fieldValue,
64+
fieldValue.VariableDefinition.Type.String(),
65+
value.Definition.Name,
66+
),
67+
At(fieldValue.VariableDefinition.Position),
68+
At(fieldValue.Position),
69+
)
70+
}
71+
}
72+
})
4573
},
4674
}

0 commit comments

Comments
 (0)