New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@workpop/graphql-mock-directive

Package Overview
Dependencies
Maintainers
17
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@workpop/graphql-mock-directive

In an effort to consolidate GraphQL mocks so that all clients (web, mobile, services) can benefit from schema first development, we are introducing a `mock` directive.

0.1.1
latest
npm
Version published
Weekly downloads
3
Maintainers
17
Weekly downloads
 
Created
Source

Mock Directive

In an effort to consolidate GraphQL mocks so that all clients (web, mobile, services) can benefit from schema first development, we are introducing a mock directive.

To take advantage of this directive on your GraphQL type include:

Before

type User {
  _id: ID
  firstName: String
  lastName: String
}

After

type User {
  _id: ID @mock(type: ID)
  firstName: String @mock(type: firstName)
  lastName: String @mock(type: lastName)
}

With these in place, if we make a request to a Roxy server with the header gql-mock, the server will respond with mock data for any fields that have this directive.

How it works

We define our mock directive types [here] We define a MockDirective [here]

Under the hood faker.js is substituting the value in its library based on the type argument provided to the mock directive.

Adding new mocks

  • Define your enum in mockTypes via mockDefinition.graphql
  • Implement your type via mockRegistry.js
  • Decorate your GraphQL type with the directive.

FAQs

Package last updated on 13 May 2018

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