graphql-validate-fixtures
Validates JSON fixtures for GraphQL responses against the associated operations and schema
Last updated 4 months ago by shopify-dep .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install graphql-validate-fixtures 
SYNC missed versions from official npm registry.

graphql-validate-fixtures

Validates JSON fixtures for GraphQL responses against the associated operations and schema

Installation

npm install graphql-validate-fixtures --save-dev

or, with Yarn:

yarn add graphql-validate-fixtures --dev

Usage

In order to associate a fixture with a GraphQL query or mutation in your app, you must follow one of these conventions:

  • Your fixtures are in a directory with a name matching that of the associated GraphQL operation
  • Your fixtures have a key called @operation at the top level, which has a string value that is the name of the associated operation

Once this is done, you can validate your fixtures using the CLI or Node.js API.

Operation

On startup this tool performs the following actions:

  • Loads all schemas
  • Discovers all operations belonging to each schema
  • Discovers all fixtures and infers operation names as described above
  • Validates fixtures against the operation with a matching name
    • Reports operation not found error if no schema matches
    • Reports ambiguous operation name error if more than one schema matches

Configuration

This tool reads schema information from a .graphqlconfig file in the project root.

CLI

# Must provide a list of fixtures as the first argument
yarn run graphql-validate-fixtures 'src/**/fixtures/**/*.graphql.json'

Node

const {evaluateFixtures} = require('graphql-validate-fixtures');
evaluateFixtures({
  fixturePaths: ['test/fixtures/one.json', 'test/fixtures/two.json'],
}).then((results) => {
  // See the TypeScript definition file for more details on the
  // structure of the `results`
  results.forEach((result) => console.log(result));
});

Current Tags

  • 0.11.2                                ...           latest (4 months ago)
  • 0.11.0-beta.1                                ...           next (5 months ago)

27 Versions

  • 0.11.2                                ...           4 months ago
  • 0.11.1                                ...           4 months ago
  • 0.11.0                                ...           5 months ago
  • 0.11.0-beta.1                                ...           5 months ago
  • 0.10.2                                ...           5 months ago
  • 0.10.1                                ...           10 months ago
  • 0.10.0                                ...           10 months ago
  • 0.9.1                                ...           10 months ago
  • 0.9.0-beta.3                                ...           10 months ago
  • 0.9.0-beta.2                                ...           10 months ago
  • 0.9.0-beta.1                                ...           a year ago
  • 0.8.5                                ...           a year ago
  • 0.8.4                                ...           a year ago
  • 0.8.3                                ...           a year ago
  • 0.8.2                                ...           a year ago
  • 0.8.1                                ...           a year ago
  • 0.7.2                                ...           2 years ago
  • 0.7.1                                ...           2 years ago
  • 0.7.0                                ...           2 years ago
  • 0.6.0                                ...           2 years ago
  • 0.5.2                                ...           2 years ago
  • 0.5.1                                ...           2 years ago
  • 0.5.0                                ...           2 years ago
  • 0.4.0                                ...           2 years ago
  • 0.3.0                                ...           2 years ago
  • 0.2.0                                ...           2 years ago
  • 0.1.0                                ...           2 years ago
Downloads
Today 0
This Week 27
This Month 81
Last Day 27
Last Week 0
Last Month 1
Dependencies (8)
Dev Dependencies (0)
None

Copyright 2014 - 2017 © taobao.org |