Registry / devops / graphql-codegen-introspection

graphql-codegen-introspection

JSON →
library0.18.2jsnpmunverified

Plugin for GraphQL Code Generator that produces a JSON file containing the introspection result of a GraphQL schema. It is stable at version 0.18.2 and has been in maintenance mode since v1 of @graphql-codegen/cli. It is mainly used for schema delivery or tooling. Released as part of the graphql-code-generator monorepo. Key differentiator: outputs raw introspection JSON, unlike other plugins that generate code.

npm install graphql-codegen-introspection
INSTALL
IMPORT
SIG · GRAPHQL-CODEGEN-IN
G
graphql-codegen-introspection
devopsjavascriptv0.18.2
harness data pending
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.
fix
Upgrade 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.
fix
Use 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.
fix
Install 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.
fix
Update 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.
fix
Do 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.
fix
Ensure @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.
fix
Build 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.
fix
Use import { plugin } from '@graphql-codegen/introspection'.
Upgrade
Version history
0.18.2latest on npm
Audit
Dependencies
graphqlrequiredPeer dependency required for introspection query execution.
Agent activity
6 hits · last 30 days
node
6
Resources
graphql-codegen-introspection — npm install graphql-codegen-introspection · libregistry