Skip to content
This repository was archived by the owner on Mar 20, 2023. It is now read-only.

Commit f443efc

Browse files
danielreardenIvanGoncharov
authored andcommitted
Update README to show how to disable introspection
1 parent 97804e7 commit f443efc

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,27 @@ export function DisallowMetadataQueries(context) {
308308
}
309309
```
310310

311+
### Disabling introspection
312+
313+
Disabling introspection does not reflect best practices and does not necessarily make your
314+
application any more secure. Nevertheless, disabling introspection is possible by utilizing the
315+
`NoSchemaIntrospectionCustomRule` provided by the [graphql-js](https://github.com/graphql/graphql-js)
316+
package.
317+
318+
```js
319+
import { specifiedRules, NoSchemaIntrospectionCustomRule } from 'graphql';
320+
321+
app.use(
322+
'/graphql',
323+
graphqlHTTP((request) => {
324+
return {
325+
schema: MyGraphQLSchema,
326+
validationRules: [...specifiedRules, NoSchemaIntrospectionCustomRule],
327+
};
328+
}),
329+
);
330+
```
331+
311332
## Other Exports
312333

313334
**`getGraphQLParams(request: Request): Promise<GraphQLParams>`**

0 commit comments

Comments
 (0)