Huge News!Announcing our $40M Series B led by Abstract Ventures.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.0
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-50%
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

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

FAQs

Package last updated on 01 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

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