A JavaScript API and CLI to test a GraphQL server for GraphQL HTTP spec compliance.
To install from npm run:
npm install test-graphql-http --save-dev
Then create and run a GraphQL server that implements the test schema.
Finally use either the function testGraphqlHttp
or the CLI with the GraphQL server URI to run the tests.
- Linux, macOS.
- Node.js v10+.
The test-graphql-http
command tests that a GraphQL server at a given URI implements the test schema and complies with the GraphQL HTTP spec. It outputs test results to stdout
and stderror
accordingly, and exits with status 1
if tests failed.
It implements the function testGraphqlHttp
and has one argument; the GraphQL server URI.
npx example:
npx test-graphql-http http://localhost:3001/graphql
Tests that a GraphQL server at a given URI implements the test schema and complies with the GraphQL HTTP spec. It outputs test results to the console, and if tests failed sets the process.exitCode
to 1
, optionally throwing an error.
Parameter | Type | Description |
---|---|---|
uri |
string | GraphQL server URI. |
throwOnFailure |
boolean? | After tests run, should an error be thrown if some failed. |
Returns: Promise<void> — Resolves once tests are complete.
How to import.
const { testGraphqlHttp } = require('test-graphql-http')
The test GraphQL schema that a GraphQL server should implement for testing with testGraphqlHttp
.
Type: GraphQLSchema
How to import.
const { schema } = require('test-graphql-http')