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

graphql-directive-retry

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphql-directive-retry

A GraphQL schema directive to retry resolvers


Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

graphql-directive-retry

npm Greenkeeper badge Build Status Coverage Status

Instead of adding retry logic inside the resolver implementation, use this schema directive to add retry declaratively

Usage

const { retryDirective, retryDeclaration } = require('@lifeomic/graphql-directive-retry');
const { makeExecutableSchema } = require('graphql-tools');
const { graphql } = require('graphql');

const typeDefs = `
  ${retryDeclaration('retry')}

  type Query {
    flakyFunction(arg: String!): String! @retry(maxTimeout: 100)
  }
`;

Customizing timeout behavior

This directive is based on promise-retry and you can use the same configuration options.

Field Config

You can configure retry behavior on a per-field basis like this:

type Query {
  flakyFunction(arg: String!): String!
    @retry(retries: 1, minTimeout: 100, maxTimeout: 200, factor: 1.1)
}
Global Config

You can configure the default retry behavior for all resovlers with a retry directive by providing the configuration in the execution context. Here is an example:

const response = await graphql(
  yourSchema,
  yourQuery,
  rootObject,
  {
    ... yourContext
    retryDirectiveConfig: {
      retries: 0
    }
  },
  {}
);

FAQs

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