Registry / api / graphql-fetch

graphql-fetch

JSON →
library1.0.1jsnpmunverified

Thin GraphQL client powered by fetch. Current stable version 1.0.1 (last released in 2016). Very minimal wrapper around fetch that sends POST requests with JSON body. No built-in caching, batching, or subscriptions. Different from Apollo Client or urql in that it offers zero abstraction over HTTP—just a convenience function. Ideal for simple use cases where you want to avoid heavy dependencies. Low release cadence; not actively maintained.

npm install graphql-fetch
INSTALL
IMPORT
SIG · GRAPHQL-FETCH
G
graphql-fetch
apijavascriptv1.0.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.

graphql-fetch
✓ import graphqlFetch from 'graphql-fetch'
✗ const graphqlFetch = require('graphql-fetch')
Package has no default export in ES module mode; use default import for ESM.
createClient
✓ import createClient from 'graphql-fetch'
The package exports a factory function that creates a fetch client. Commonly misnamed as default import.
require
✓ const fetch = require('graphql-fetch')('http://example.com/graphql')
✗ const graphqlFetch = require('graphql-fetch')()
Requiring returns a factory function; you must immediately call it with the GraphQL endpoint URL.

Shows creating a client from an endpoint, executing a query with variables, handling errors.

import graphqlFetch from 'graphql-fetch'; const endpoint = process.env.GRAPHQL_ENDPOINT ?? 'http://localhost:4000/graphql'; const fetchClient = graphqlFetch(endpoint); const query = ` query GetUser($id: ID!) { user(id: $id) { name email } } `; const variables = { id: '123' }; fetchClient(query, variables) .then(result => { if (result.errors) { console.error('GraphQL errors:', result.errors); return; } console.log('User:', result.data.user); }) .catch(err => console.error('Network error:', err));
Debug
Known issues
deprecatedPackage is no longer actively maintained; no updates since 2016.
fix
Consider migrating to a modern client like graphql-request or Apollo Client.
affects: >=1.0.0
gotchaisomorphic-fetch is a hard dependency; it makes fetch globally available which may conflict with other polyfills.
fix
Ensure no other fetch polyfill is loaded, or use a bundler that avoids duplicates.
affects: >=1.0.0
gotchaNo automatic parsing of errors; errors object may be null or undefined.
fix
Always check result.errors existence before accessing data.
affects: >=1.0.0
breakingThe package uses CommonJS require() and does not provide ESM exports.
fix
Use dynamic import or a bundler that handles CJS.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: graphqlFetch is not a function
Using ES import with named import instead of default.
fix
Use default import: import graphqlFetch from 'graphql-fetch'
Uncaught ReferenceError: fetch is not defined
Running in Node.js without isomorphic-fetch polyfill.
fix
Install isomorphic-fetch or use Node 18+ with global fetch.
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
40 hits · last 30 days
node
36
Resources
graphql-fetch — npm install graphql-fetch · libregistry