Nocturnally Psychologizing Millipede

    graphql-validate-fixtures
    TypeScript icon, indicating that this package has built-in type declarations

    2.1.2 • Public • Published

    graphql-validate-fixtures

    Build Status Build Status License: MIT npm version

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

    Installation

    $ yarn add graphql-validate-fixtures

    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));
    });

    Keywords

    none

    Install

    npm i graphql-validate-fixtures

    DownloadsWeekly Downloads

    36,840

    Version

    2.1.2

    License

    MIT

    Unpacked Size

    62.3 kB

    Total Files

    24

    Last publish

    Collaborators

    • lemonmade
    • shopify-dep