Skip to content

Latest commit

 

History

History
31 lines (26 loc) · 876 Bytes

defer-stream.md

File metadata and controls

31 lines (26 loc) · 876 Bytes
title sidebar_label
Enabling Defer & Stream
Enabling Defer & Stream

The @defer and @stream directives are not enabled by default. In order to use these directives, you must add them to your GraphQL Schema and use the experimentalExecuteIncrementally function instead of execute.

import {
  GraphQLSchema,
  GraphQLDeferDirective,
  GraphQLStreamDirective,
  specifiedDirectives,
} from 'graphql';

const schema = new GraphQLSchema({
  query,
  directives: [
    ...specifiedDirectives,
    GraphQLDeferDirective,
    GraphQLStreamDirective,
  ],
});

const result = experimentalExecuteIncrementally({
  schema,
  document,
});

If the directives option is passed to GraphQLSchema, the default directives will not be included. specifiedDirectives must be passed to ensure all standard directives are added in addition to defer & stream.