Registry / devops / gql-fetch

gql-fetch

JSON →
library0.3.9jsnpmunverified

A lightweight GraphQL client using the fetch API, designed for Node.js and browser environments. Current stable version is 0.3.9, but the package appears to be in early development with no recent releases. It supports file uploads, request aborting, and RxJS Observables. Provides both a class-based `GQLClient` and a functional `getFetch` API. Includes a fetch polyfill for older browsers. Differentiators include built-in file upload support via multipart requests and Observable integration, but compared to mature clients like Apollo Client or urql, it lacks subscriptions, caching, and React integration.

npm install gql-fetch
INSTALL
IMPORT
SIG · GQL-FETCH
G
gql-fetch
devopsjavascriptv0.3.9
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.

GQLClient
import { GQLClient } from 'gql-fetch'
import GQLClient from 'gql-fetch'
Named export only; default import is incorrect.
getFetch
import { getFetch } from 'gql-fetch'
const getFetch = require('gql-fetch').getFetch
Named export; require with destructuring is fine but less common.
GQLRequest
import { GQLRequest } from 'gql-fetch'
TypeScript users may want to import GQLRequest for type annotations.

Creates a GQLClient, sends a query with variables, handles response or error, and demonstrates abort capability.

import { GQLClient } from 'gql-fetch'; const client = new GQLClient('https://api.example.com/graphql'); const query = ` query ($id: Int!) { user(id: $id) { id name } } `; const variables = { id: 1 }; client.fetch(query, variables) .then(response => { console.log(response.data); }) .catch(error => { console.error(error); }); // Abort example: const request = client.fetch(query, variables); // request.abort();
Debug
Known issues
gotchaPackage has not been updated in over 4 years; may have compatibility issues with modern Node.js and fetch implementations.
fix
Consider using actively maintained alternatives like Apollo Client, urql, or graphql-request.
affects: *
gotchaThe library uses a custom fetch polyfill which may conflict with existing fetch polyfills or global fetch in browser environments.
fix
Ensure no duplicate fetch polyfills are loaded; test in target browsers.
affects: *
gotchaRxJS Observable support requires a peer dependency on rxjs, which is not declared in package.json.
fix
Install rxjs separately: npm install rxjs
affects: *
gotchaFile upload uses fs.createReadStream, which is Node.js-specific; browser usage may require Blob/File.
fix
Use the Blob or File API in browser environment instead of fs.createReadStream.
affects: *
Errors
Common errors & fixes
TypeError: client.fetch is not a function
Using default import instead of named import: import GQLClient from 'gql-fetch'
fix
Use named import: import { GQLClient } from 'gql-fetch'
Cannot find module 'gql-fetch' when using require
CommonJS require is not supported by the package; it exports ES modules.
fix
Use ES module import syntax: import { GQLClient } from 'gql-fetch'
Observable is not defined
rxjs package is not installed; it is an undeclared peer dependency.
fix
Install rxjs: npm install rxjs
Upgrade
Version history
0.3.9latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
gql-fetch — npm install gql-fetch · libregistry