Registry / devops / fetch-graphql-schema

fetch-graphql-schema

JSON →
library0.2.1jsnpmunverified

A minimal CLI and Node.js library (v0.2.1, last updated March 2018) for fetching a GraphQL schema via an introspection query and outputting JSON or readable SDL. Currently in maintenance mode with no active development. Simpler than graphql-cli's introspection command, with no dependency on graphql-core; plain HTTP fetch and JSON parse.

npm install fetch-graphql-schema
INSTALL
IMPORT
SIG · FETCH-GRAPHQL-SCHE
F
fetch-graphql-schema
devopsjavascriptv0.2.1
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.

fetchSchema
const fetchSchema = require('fetch-graphql-schema');
import fetchSchema from 'fetch-graphql-schema';
Package is CommonJS-only; ESM import will fail unless using bundler.
fetchGraphqlSchema
const fetchGraphqlSchema = require('fetch-graphql-schema');
const { fetchGraphqlSchema } = require('fetch-graphql-schema');
Default export is a single function; named destructuring yields undefined.
CLI
npx fetch-graphql-schema http://example.com/graphql
fetch-graphql-schema
CLI usage requires URL argument; no positional args defaults to error.

Fetches a GraphQL schema via introspection and logs the result in readable SDL format.

const fetchSchema = require('fetch-graphql-schema'); fetchSchema('https://api.example.com/graphql', { readable: true }) .then(schema => { console.log(schema); }) .catch(err => { console.error(err); });
Debug
Known issues
deprecatedNode.js < 8.0.0 required for older versions; modern Node may need polyfills for fetch.
fix
Use Node >= 8 or rely on built-in fetch (experimental in 18+).
affects: >=0.2.0
gotchaoptions object is passed directly to node-fetch; unknown options may cause unexpected behavior.
fix
Only use documented options: { readable, headers, method }.
affects: *
breakingCLI exit code is 0 even on introspection errors; JSON output may be invalid.
fix
Check stderr or validate JSON output manually.
affects: *
Errors
Common errors & fixes
TypeError: fetchSchema is not a function
Using ESM import instead of CommonJS require
fix
Use const fetchSchema = require('fetch-graphql-schema');
Error: read ECONNREFUSED
GraphQL endpoint is not running or blocked
fix
Ensure server is running and URL is correct.
fetchSchema(...) is not a function
Destructuring default export incorrectly
fix
Do not use curly braces; assign default export directly.
Upgrade
Version history
0.2.1latest on npm
Audit
Dependencies
node-fetchrequiredHTTP requests to the GraphQL endpoint
Agent activity
2 hits · last 30 days
node
2
Resources
fetch-graphql-schema — npm install fetch-graphql-schema · libregistry