Skip to content

Commit

Permalink
Add defer/stream tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
robrichard committed May 26, 2022
1 parent fd2894b commit 4e044e4
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
26 changes: 26 additions & 0 deletions website/docs/tutorials/defer-stream.md
Original file line number Diff line number Diff line change
@@ -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`.
1 change: 1 addition & 0 deletions website/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ module.exports = {
items: ['tutorials/constructing-types'],
},
'tutorials/express-graphql',
'tutorials/defer-stream',
],
};

0 comments on commit 4e044e4

Please sign in to comment.