Registry /
devops / graphql-codegen-introspection
Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
default import
✓ import introspection from '@graphql-codegen/introspection'
✗ const introspection = require('@graphql-codegen/introspection')
Package is ESM-only; CommonJS require is not supported.
IntrospectionConfig
✓ import type { IntrospectionConfig } from '@graphql-codegen/introspection'
✗ import { IntrospectionConfig } from '@graphql-codegen/introspection' (non-type import works but not best practice)
TypeScript type export; use `import type` to avoid runtime inclusion.
plugin export
✓ import { plugin } from '@graphql-codegen/introspection'
✗ import plugin from '@graphql-codegen/introspection'
Named export for the plugin function; default export is not available.
Shows how to configure in codegen.yml and programmatically use the introspection plugin.
// codegen.yml
schema: './schema.graphql'
documents: []
plugs:
- '@graphql-codegen/introspection'
config:
introspection:
descriptions: true
directiveIsRepeatable: true
schemaDescription: true
specifiedByUrl: true
# Or programmatic usage:
import { plugin } from '@graphql-codegen/introspection';
import { buildSchema } from 'graphql';
const schema = buildSchema(`
type Query {
hello: String
}
`);
const result = await plugin(schema, [], {}, { filename: 'schema.json' });
console.log(result); // Contains introspection JSON as string
Debug
Known issues
deprecatedThis plugin is deprecated in favor of @graphql-codegen/introspection from the new v1 packages.fixUpgrade to @graphql-codegen/cli v1 and use @graphql-codegen/introspection from the new monorepo.
affects: >=0.18.0
gotchaThe plugin output is a string, not a JSON object; it must be written to a file or parsed if used programmatically.fixUse JSON.parse(result) if you need the object, or write to file.
affects: >=0.1.0
gotchaGraphQL peer dependency range is extremely wide; ensure your GraphQL version is compatible with the introspection query produced.fixInstall graphql >=14.0.0 for best compatibility.
affects: >=0.1.0
breakingVersion 0.18.x uses the new plugin API; previous 0.17.x plugins are incompatible configuration-wise.fixUpdate config format to match v0.18 API. See migration guide.
affects: >=0.18.0 <0.19.0
gotchaThe plugin does not support documents; it only introspects the schema.fixDo not include documents in the plugin config; use other plugins for client-side operations.
affects: >=0.1.0
Errors
Common errors & fixes
Cannot find module '@graphql-codegen/introspection'
Package name changed or not installed.
fixEnsure @graphql-codegen/introspection is in dependencies. For old codegen, use 'graphql-codegen-introspection'.
Error: introspection plugin: schema is not a valid GraphQLSchema object
Passing a string instead of a parsed schema object when using programmatic API.
fixBuild schema with buildSchema or use introspectionFromSchema from graphql.
TypeError: introspection is not a function
Incorrect import; trying to use default import when plugin is a named export.
fixUse import { plugin } from '@graphql-codegen/introspection'. Audit
Dependencies
graphqlrequiredPeer dependency required for introspection query execution.