A collection of simple utilities for working with GraphQL APIs using the reference JS GraphQL implementation.
npm install
A config.json
file is provided with the following options:
- outputPath: location to write output files
- fileNames: a list of default output file names
You may also configure a .env
file for your API (see .env.example
):
ID_TOKEN
: a valid JWT if your API requires anAuthorization
header (may also be provided via the commandline)API_HOST
: the absolute url of your GraphQL API (may also be provided via the commandline)
Utility scripts are provided as follows:
Perform an introspection query and write the result to disk.
npm run introspect
Create a GraphQLSchema object from the result of the introspection query and write it to disk.
npm run generate-schema-object
Create a schema string from the result of the introspection query and write it to disk.
npm run generate-schema-string
Creates a fragment types JSON file from the result of the introspection query and write it to disk. The resulting file can be used in Apollo Client's IntrospectionFragmentMatcher
as a solution for working with unions/interfaces.