Introduction
Introspection control lets you decide if people can ask your GraphQL server about its own structure. This helps keep your data safe and your server fast.
Jump into concepts and practice - no test required
Introspection control lets you decide if people can ask your GraphQL server about its own structure. This helps keep your data safe and your server fast.
const server = new ApolloServer({ typeDefs, resolvers, introspection: true // or false });
introspection to true to allow introspection queries.introspection to false to disable introspection queries.const server = new ApolloServer({ typeDefs, resolvers, introspection: true });
const server = new ApolloServer({ typeDefs, resolvers, introspection: false });
This GraphQL server has introspection disabled, so clients cannot query the schema structure.
const { ApolloServer, gql } = require('apollo-server'); const typeDefs = gql` type Query { hello: String } `; const resolvers = { Query: { hello: () => 'Hello world!' } }; const server = new ApolloServer({ typeDefs, resolvers, introspection: false }); server.listen().then(({ url }) => { console.log(`Server ready at ${url}`); });
Disabling introspection improves security but can make debugging harder.
Consider enabling introspection only in development environments.
Some tools rely on introspection to work properly.
Introspection control lets you allow or block schema queries.
Use it to protect your API and improve performance.
Toggle with the introspection option in your server setup.
introspection control in GraphQL?introspection: true or introspection: false.introspection: false disables introspection queries.const server = new ApolloServer({
typeDefs,
resolvers,
introspection: false
});introspection: falseconst server = new ApolloServer({
typeDefs,
resolvers,
introspection: 'false'
});