5.0.0 • Published 9 months ago

parrot-graphql v5.0.0

Weekly downloads
283
License
Apache-2.0
Repository
github
Last release
9 months ago

parrot-graphql is a helper library that resolves GET and POST requests to your GraphQL endpoint using mocking logic that is defined for each schema type. Under the hood, parrot-graphql is a small wrapper around @graphql-tools/mock mockServer.

For in-depth examples on how to write mock resolvers, read the above documentation from graphql-tools, but below is a simple example to start you on your way.

Example

// scenarios.js
const graphql = require('parrot-graphql');
const casual = require('casual'); // A nice mocking tool

const schema = `
type Query {
  shiplog: [ShipLog]
}

type ShipLog {
  Name: String!
  Captain: String!
}
`;

const scenarios = {
  'has a ship log from GraphQL': [
    graphql('/graphql', schema, {
      Name: () => 'Jolly Roger',
      Captain: () => casual.name,
    }),
  ],
};

module.exports = scenarios;

API

graphql(path, schema, mocks)

Creates a function for your GraphQL endpoint.

Arguments

  • path (String): Path of your GraphQL endpoint.
  • schema (String): GraphQL schema string.
  • mocks (Object): Object describing your mocking logic that is passed to graphql-tools mockServer.
5.0.0

9 months ago

5.0.0-alpha.1

2 years ago

5.0.0-alpha.0

3 years ago

4.1.1

4 years ago

4.1.0

4 years ago

4.0.1

4 years ago

3.0.0

6 years ago