Registry / devtools / get-graphql-schema

get-graphql-schema

JSON →
library2.1.2jsnpmunverified

CLI tool to fetch and print the GraphQL schema from a GraphQL HTTP endpoint. Current stable version is 2.1.2, released in 2018, with low release cadence (no updates since 2019). It outputs schema in IDL syntax by default, with optional JSON output. Alternatives like graphql-cli offer richer workflows. Supports custom headers via --header flag. Suitable for quick schema retrieval, especially for Relay Modern projects.

npm install get-graphql-schema
INSTALL
IMPORT
SIG · GET-GRAPHQL-SCHEMA
G
get-graphql-schema
devtoolsjavascriptv2.1.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.

getGraphQLSchema
import { getGraphQLSchema } from 'get-graphql-schema'
const getGraphQLSchema = require('get-graphql-schema')
ESM-only package, no CommonJS support

Fetch and print the GraphQL schema from a public endpoint using custom headers, output SDL.

import { getGraphQLSchema } from 'get-graphql-schema'; const endpoint = 'https://api.example.com/graphql'; const headers = { 'Authorization': 'Bearer ' + (process.env.AUTH_TOKEN ?? '') }; getGraphQLSchema(endpoint, { headers }).then(schema => { console.log(schema); // prints SDL schema }).catch(err => { console.error('Failed to fetch schema:', err); });
Debug
Known issues
deprecatedPackage is effectively deprecated; consider using graphql-cli for improved workflows.
fix
Use graphql-cli or graphql-request with introspection query.
affects: >=2.0.0
breakingESM-only since v2.0.0 - no CommonJS support.
fix
Use dynamic import() or switch to CommonJS-compatible library.
affects: >=2.0.0
gotchaThe library does not validate the endpoint URL or handle network errors gracefully.
fix
Wrap calls in try-catch and validate URL before passing.
affects: *
Errors
Common errors & fixes
Error: Cannot find module 'get-graphql-schema'
Using require() in a CommonJS context; package is ESM-only.
fix
Use import statement or dynamic import: const { getGraphQLSchema } = await import('get-graphql-schema');
TypeError: getGraphQLSchema is not a function
Incorrect import (default vs named).
fix
Use named import: import { getGraphQLSchema } from 'get-graphql-schema';
Upgrade
Version history
2.1.2latest on npm
Audit
Dependencies
graphqlrequiredUsed for parsing and printing the schema
Agent activity
27 hits · last 30 days
node
24
Resources
get-graphql-schema — npm install get-graphql-schema · libregistry