Skip to content

Commit

Permalink
Update spec support for latest draft version (#342)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
CodingContraption and StevenACoffman authored Jan 27, 2025
1 parent 217e304 commit 4de5ffd
Show file tree
Hide file tree
Showing 41 changed files with 1,387 additions and 420 deletions.
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ gqlparser [![CircleCI](https://badgen.net/circleci/github/vektah/gqlparser/maste

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

spec target: June 2018 (Schema definition language, block strings as descriptions, error paths & extension)
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.

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

Expand Down
5 changes: 5 additions & 0 deletions validator/imported/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# .npmrc
# engine-strict=true is so npm will stubbornly refuse
# to install (or even consider installing) any package
# that claims to not be compatible with the current Node.js version.
engine-strict=true
2 changes: 1 addition & 1 deletion validator/imported/export.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fs from "fs";
import Module from "module";
import { testSchema } from "./graphql-js/src/validation/__tests__/harness";
import { printSchema } from "./graphql-js/src/utilities";
import { printSchema } from "./graphql-js/src";
import yaml from "js-yaml";

let schemas = [];
Expand Down
6 changes: 3 additions & 3 deletions validator/imported/export.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ GIT_REF=origin/main
if [[ -f "$EXPORTER_ROOT/graphql-js-commit.log" ]] ; then
GIT_REF=$(cat "$EXPORTER_ROOT/graphql-js-commit.log")
fi
echo $GIT_REF
echo "$GIT_REF"

if [[ -d "$REPO_DIR" ]] ; then
echo "fetching graphql-js with ${GIT_REF}"
cd "$REPO_DIR" || exit
git fetch origin master
git fetch origin main
git checkout "$GIT_REF"
git reset --hard
else
Expand All @@ -24,7 +24,7 @@ else
cd "$REPO_DIR" || exit
git checkout "$GIT_REF"
fi
git rev-parse HEAD > $EXPORTER_ROOT/graphql-js-commit.log
git rev-parse HEAD > "$EXPORTER_ROOT/graphql-js-commit.log"

cd "$EXPORTER_ROOT" || exit

Expand Down
2 changes: 1 addition & 1 deletion validator/imported/graphql-js-commit.log
Original file line number Diff line number Diff line change
@@ -1 +1 @@
f597c694339b7c488f05496806e404659f6ff955
48afd37a48d37f6d3342b959e8cb34e1ecbfeffb
3 changes: 3 additions & 0 deletions validator/imported/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,8 @@
},
"devDependencies": {
"prettier": "^3.4.2"
},
"engines": {
"node": ">= 22"
}
}
6 changes: 5 additions & 1 deletion validator/imported/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

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

```shell script
# update to latest
Expand All @@ -11,3 +11,7 @@ $ rm graphql-js-commit.log && ./export.sh
# re-generate with known revision
$ ./export.sh
```

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.

Please in your PR description note the git release tag that corresponds to the graphql-js commit.
8 changes: 4 additions & 4 deletions validator/imported/spec/ExecutableDefinitionsRule.spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
name
}
}
errors: []
- name: with operation and fragment
rule: ExecutableDefinitions
Expand All @@ -25,7 +25,7 @@
fragment Frag on Dog {
name
}
errors: []
- name: with type definition
rule: ExecutableDefinitions
Expand All @@ -45,7 +45,7 @@
extend type Dog {
color: String
}
errors:
- message: The "Cow" definition is not executable.
locations:
Expand All @@ -67,7 +67,7 @@
}
extend schema @directive
errors:
- message: The schema definition is not executable.
locations:
Expand Down
38 changes: 19 additions & 19 deletions validator/imported/spec/FieldsOnCorrectTypeRule.spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
__typename
name
}
errors: []
- name: Aliased object field selection
rule: FieldsOnCorrectType
Expand All @@ -18,7 +18,7 @@
tn : __typename
otherName : name
}
errors: []
- name: Interface field selection
rule: FieldsOnCorrectType
Expand All @@ -29,7 +29,7 @@
__typename
name
}
errors: []
- name: Aliased interface field selection
rule: FieldsOnCorrectType
Expand All @@ -39,7 +39,7 @@
fragment interfaceFieldSelection on Pet {
otherName : name
}
errors: []
- name: Lying alias selection
rule: FieldsOnCorrectType
Expand All @@ -49,7 +49,7 @@
fragment lyingAliasSelection on Dog {
name : nickname
}
errors: []
- name: Ignores fields on unknown type
rule: FieldsOnCorrectType
Expand All @@ -59,7 +59,7 @@
fragment unknownSelection on UnknownType {
unknownField
}
errors: []
- name: reports errors when type is known again
rule: FieldsOnCorrectType
Expand All @@ -73,7 +73,7 @@
}
}
}
errors:
- message: Cannot query field "unknown_pet_field" on type "Pet".
locations:
Expand All @@ -89,7 +89,7 @@
fragment fieldNotDefined on Dog {
meowVolume
}
errors:
- message: Cannot query field "meowVolume" on type "Dog". Did you mean "barkVolume"?
locations:
Expand All @@ -104,7 +104,7 @@
deeper_unknown_field
}
}
errors:
- message: Cannot query field "unknown_field" on type "Dog".
locations:
Expand All @@ -119,7 +119,7 @@
unknown_field
}
}
errors:
- message: Cannot query field "unknown_field" on type "Pet".
locations:
Expand All @@ -134,7 +134,7 @@
meowVolume
}
}
errors:
- message: Cannot query field "meowVolume" on type "Dog". Did you mean "barkVolume"?
locations:
Expand All @@ -147,7 +147,7 @@
fragment aliasedFieldTargetNotDefined on Dog {
volume : mooVolume
}
errors:
- message: Cannot query field "mooVolume" on type "Dog". Did you mean "barkVolume"?
locations:
Expand All @@ -160,7 +160,7 @@
fragment aliasedLyingFieldTargetNotDefined on Dog {
barkVolume : kawVolume
}
errors:
- message: Cannot query field "kawVolume" on type "Dog". Did you mean "barkVolume"?
locations:
Expand All @@ -173,7 +173,7 @@
fragment notDefinedOnInterface on Pet {
tailLength
}
errors:
- message: Cannot query field "tailLength" on type "Pet".
locations:
Expand All @@ -186,7 +186,7 @@
fragment definedOnImplementorsButNotInterface on Pet {
nickname
}
errors:
- message: Cannot query field "nickname" on type "Pet". Did you mean to use an inline fragment on "Cat" or "Dog"?
locations:
Expand All @@ -199,7 +199,7 @@
fragment directFieldSelectionOnUnion on CatOrDog {
__typename
}
errors: []
- name: Direct field selection on union
rule: FieldsOnCorrectType
Expand All @@ -209,7 +209,7 @@
fragment directFieldSelectionOnUnion on CatOrDog {
directField
}
errors:
- message: Cannot query field "directField" on type "CatOrDog".
locations:
Expand All @@ -222,7 +222,7 @@
fragment definedOnImplementorsQueriedOnUnion on CatOrDog {
name
}
errors:
- message: Cannot query field "name" on type "CatOrDog". Did you mean to use an inline fragment on "Pet", "Cat", or "Dog"?
locations:
Expand All @@ -240,5 +240,5 @@
name
}
}
errors: []
20 changes: 10 additions & 10 deletions validator/imported/spec/FragmentsOnCompositeTypesRule.spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
fragment validFragment on Dog {
barks
}
errors: []
- name: interface is valid fragment type
rule: FragmentsOnCompositeTypes
Expand All @@ -16,7 +16,7 @@
fragment validFragment on Pet {
name
}
errors: []
- name: object is valid inline fragment type
rule: FragmentsOnCompositeTypes
Expand All @@ -28,7 +28,7 @@
barks
}
}
errors: []
- name: interface is valid inline fragment type
rule: FragmentsOnCompositeTypes
Expand All @@ -40,7 +40,7 @@
name
}
}
errors: []
- name: inline fragment without type is valid
rule: FragmentsOnCompositeTypes
Expand All @@ -52,7 +52,7 @@
name
}
}
errors: []
- name: union is valid fragment type
rule: FragmentsOnCompositeTypes
Expand All @@ -62,7 +62,7 @@
fragment validFragment on CatOrDog {
__typename
}
errors: []
- name: scalar is invalid fragment type
rule: FragmentsOnCompositeTypes
Expand All @@ -72,7 +72,7 @@
fragment scalarFragment on Boolean {
bad
}
errors:
- message: Fragment "scalarFragment" cannot condition on non composite type "Boolean".
locations:
Expand All @@ -85,7 +85,7 @@
fragment scalarFragment on FurColor {
bad
}
errors:
- message: Fragment "scalarFragment" cannot condition on non composite type "FurColor".
locations:
Expand All @@ -98,7 +98,7 @@
fragment inputFragment on ComplexInput {
stringField
}
errors:
- message: Fragment "inputFragment" cannot condition on non composite type "ComplexInput".
locations:
Expand All @@ -113,7 +113,7 @@
barks
}
}
errors:
- message: Fragment cannot condition on non composite type "String".
locations:
Expand Down
Loading

0 comments on commit 4de5ffd

Please sign in to comment.