Skip to content

Commit 81827e4

Browse files
committed
feat(graphql): add mercurius plugins to docs
1 parent 823ae41 commit 81827e4

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

content/graphql/plugins.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
### Plugins
22

3-
> warning **Warning** This chapter applies only to the `@nestjs/apollo` driver.
3+
#### For `@nestjs/apollo` driver
44

55
Plugins enable you to extend Apollo Server's core functionality by performing custom operations in response to certain events. Currently, these events correspond to individual phases of the GraphQL request lifecycle, and to the startup of Apollo Server itself (read more [here](https://www.apollographql.com/docs/apollo-server/integrations/plugins/)). For example, a basic logging plugin might log the GraphQL query string associated with each request that's sent to Apollo Server.
66

@@ -51,3 +51,31 @@ GraphQLModule.forRoot({
5151
```
5252

5353
> info **Hint** The `ApolloServerOperationRegistry` plugin is exported from the `apollo-server-plugin-operation-registry` package.
54+
55+
#### For `@nestjs/mercurius` driver
56+
57+
Some mercurius specific fastify plugins have to be loaded after the mercurius plugin (read more [here](https://mercurius.dev/#/docs/plugins)) on the plugin tree.
58+
59+
> warning **Warning** [mercurius-upload](https://github.com/mercurius-js/mercurius-upload) is an exception and should be registered in the main file.
60+
61+
There is an optional `plugins` array parameter inside the `MercuriusDriver`, this array takes an object with the plugin function on the `plugin` parameter and its options inside an optional `options` parameter. Therefore, registering the [cache plugin](https://github.com/mercurius-js/cache) would be as follows:
62+
63+
```typescript
64+
GraphQLModule.forRoot({
65+
driver: MercuriusDriver,
66+
// ...
67+
plugins: [
68+
{
69+
plugin: cache,
70+
options: {
71+
ttl: 10,
72+
policy: {
73+
Query: {
74+
add: true
75+
}
76+
}
77+
},
78+
}
79+
]
80+
}),
81+
```

0 commit comments

Comments
 (0)