Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

graphql-validate-fixtures

Package Overview
Dependencies
Maintainers
0
Versions
83
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphql-validate-fixtures

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

  • 3.3.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

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

FAQs

Package last updated on 28 Aug 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc