-
Notifications
You must be signed in to change notification settings - Fork 491
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #633 from dackroyd/update-graphql-js-testdata-process
Upgrade graphql-js Testdata Process
- Loading branch information
Showing
13 changed files
with
2,543 additions
and
3,574 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# graphql-js testdata | ||
|
||
Test cases are generated here by extracting them from [graphql-js] into JSON that we can use to drive Go tests. | ||
|
||
## Usage | ||
|
||
To update the testdata, run the following command within the `testdata` directory: | ||
|
||
```sh | ||
go generate . | ||
``` | ||
|
||
## How it works | ||
|
||
A Node.js project is used to pull in graphql-js as a dependency, and automatically patch that via `patch-package`. These | ||
patches replace the `mocha` test functions `describe`, `it`, assertions and the test `harness`. This allows the | ||
expectations to be captured, and written to a JSON file. These test cases in the JSON file are then used to drive the Go | ||
tests. | ||
|
||
## Updating patches | ||
|
||
With changes to [graphql-js], the patches may need to be updated. To do this, update the `graphql` dependency under | ||
`node_modules`, and sync the patches with the following command: | ||
|
||
```sh | ||
npm run create-patches | ||
``` | ||
|
||
[graphql-js]: https://github.com/graphql/graphql-js |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import * as fs from 'node:fs'; | ||
import { printSchema } from 'graphql/src/utilities/printSchema.js'; | ||
import { schemas, testCases } from 'graphql/src/validation/__tests__/harness.js'; | ||
|
||
// TODO: Fix test failures. | ||
// require('graphql/src/validation/__tests__/ExecutableDefinitions-test'); | ||
import 'graphql/src/validation/__tests__/FieldsOnCorrectTypeRule-test.js'; | ||
import 'graphql/src/validation/__tests__/FragmentsOnCompositeTypesRule-test.js'; | ||
// TODO: Fix test failures. | ||
// require('graphql/src/validation/__tests__/KnownArgumentNames-test'); | ||
import 'graphql/src/validation/__tests__/KnownDirectivesRule-test.js'; | ||
import 'graphql/src/validation/__tests__/KnownFragmentNamesRule-test.js'; | ||
import 'graphql/src/validation/__tests__/KnownTypeNamesRule-test.js'; | ||
import 'graphql/src/validation/__tests__/LoneAnonymousOperationRule-test.js'; | ||
import 'graphql/src/validation/__tests__/NoFragmentCyclesRule-test.js'; | ||
import 'graphql/src/validation/__tests__/NoUndefinedVariablesRule-test.js'; | ||
import 'graphql/src/validation/__tests__/NoUnusedFragmentsRule-test.js'; | ||
import 'graphql/src/validation/__tests__/NoUnusedVariablesRule-test.js'; | ||
import 'graphql/src/validation/__tests__/OverlappingFieldsCanBeMergedRule-test.js'; | ||
// TODO: Fix test failures. | ||
// require('graphql/src/validation/__tests__/PossibleFragmentSpreads-test'); | ||
import 'graphql/src/validation/__tests__/ProvidedRequiredArgumentsRule-test.js'; | ||
import 'graphql/src/validation/__tests__/ScalarLeafsRule-test.js'; | ||
// TODO: Add support for subscriptions. | ||
// require('graphql/src/validation/__tests__/SingleFieldSubscriptions-test.js'); | ||
import 'graphql/src/validation/__tests__/UniqueArgumentNamesRule-test.js'; | ||
import 'graphql/src/validation/__tests__/UniqueDirectivesPerLocationRule-test.js'; | ||
import 'graphql/src/validation/__tests__/UniqueFragmentNamesRule-test.js'; | ||
import 'graphql/src/validation/__tests__/UniqueInputFieldNamesRule-test.js'; | ||
import 'graphql/src/validation/__tests__/UniqueOperationNamesRule-test.js'; | ||
import 'graphql/src/validation/__tests__/UniqueVariableNamesRule-test.js'; | ||
// TODO: Fix test failures. | ||
// require('graphql/src/validation/__tests__/ValuesofCorrectType-test'); | ||
import 'graphql/src/validation/__tests__/VariablesAreInputTypesRule-test.js'; | ||
// TODO: Fix test failures. | ||
// require('graphql/src/validation/__tests__/VariablesDefaultValueAllowed-test'); | ||
import 'graphql/src/validation/__tests__/VariablesInAllowedPositionRule-test.js'; | ||
|
||
let output = JSON.stringify({ | ||
schemas: schemas().map(s => printSchema(s)), | ||
tests: testCases(), | ||
}, null, 2) | ||
output = output.replace(/ Did you mean to use an inline fragment on [^?]*\?/g, ''); | ||
// Ignore suggested types in errors, which graphql-go does not currently produce. | ||
output = output.replace(/ Did you mean \\"[A-Z].*\"\?/g, ''); | ||
fs.writeFileSync("tests.json", output); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.