diff --git a/website/docs/tutorials/defer-stream.md b/website/docs/tutorials/defer-stream.md new file mode 100644 index 0000000000..5235cab4fd --- /dev/null +++ b/website/docs/tutorials/defer-stream.md @@ -0,0 +1,26 @@ +--- +title: Enabling Defer & Stream +sidebar_label: 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. + +```js +import { + GraphQLSchema, + GraphQLDeferDirective, + GraphQLStreamDirective, + specifiedDirectives, +} from 'graphql'; + +const schema = new GraphQLSchema({ + query, + directives: [ + ...specifiedDirectives, + GraphQLDeferDirective, + GraphQLStreamDirective, + ], +}); +``` + +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`. diff --git a/website/sidebars.js b/website/sidebars.js index 79fe5e9d8b..5201b4fd95 100644 --- a/website/sidebars.js +++ b/website/sidebars.js @@ -16,5 +16,6 @@ module.exports = { items: ['tutorials/constructing-types'], }, 'tutorials/express-graphql', + 'tutorials/defer-stream', ], };