{"id":47814,"library":"graphql-client","title":"graphql-client","description":"A lightweight HTTP client for GraphQL APIs built on the fetch API with isomorphic-fetch for cross-environment support. Current stable version is 2.0.1, with no recent release activity (last updated years ago). It provides a simple promise-based interface for executing queries and mutations, with built-in error handling that includes query location highlighting. Simpler than Apollo or Relay, but lacks subscriptions, caching, and active maintenance. Suitable for minimal integrations in Node.js or browsers where a full-fledged client is overkill.","status":"maintenance","version":"2.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/nordsimon/graphql-client","tags":["javascript"],"install":[{"cmd":"npm install graphql-client","lang":"bash","label":"npm"},{"cmd":"yarn add graphql-client","lang":"bash","label":"yarn"},{"cmd":"pnpm add graphql-client","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"fetch polyfill for Node.js and older browsers","package":"isomorphic-fetch","optional":true}],"imports":[{"note":"The module exports a factory function as default. Named imports will not work.","wrong":"import { client } from 'graphql-client'","symbol":"default export","correct":"import client from 'graphql-client'"},{"note":"CommonJS usage requires the entire module export.","wrong":"const { client } = require('graphql-client')","symbol":"require","correct":"const client = require('graphql-client')"},{"note":"If using TypeScript, use import type for types to avoid runtime errors. The package does not ship its own types; this assumes you have @types/graphql-client or a local declaration.","wrong":"import { ClientOptions } from 'graphql-client'","symbol":"TypeScript types","correct":"import type { ClientOptions, Client } from 'graphql-client'"}],"quickstart":{"code":"import client from 'graphql-client';\n\nconst { query, mutate } = client({\n  url: process.env.GRAPHQL_URL ?? 'https://api.example.com/graphql',\n  headers: {\n    Authorization: `Bearer ${process.env.AUTH_TOKEN ?? ''}`\n  }\n});\n\nquery(`\n  query getUser($id: ID!) {\n    user(id: $id) {\n      name email\n    }\n  }\n`, { id: '123' })\n  .then(data => console.log(data))\n  .catch(err => console.error(err.message));","lang":"typescript","description":"Demonstrates creating a client with URL and headers, then executing a query with variables."},"warnings":[{"fix":"Replace isomorphic-fetch with cross-fetch or remove polyfill if using Node 18+.","message":"isomorphic-fetch is outdated; consider using cross-fetch or native fetch in Node.js 18+.","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"Always attach a .catch() handler or use async/await with try/catch.","message":"Errors are thrown with a message and query highlight string; catch them to prevent unhandled rejections.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Destructure { query, mutate } from the factory call.","message":"The client factory returns an object with query and mutate functions, not a class instance.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Consider using a maintained alternative like graphql-request or Apollo Client.","message":"The package has not been updated in years; there may be unfixed security issues in dependencies.","severity":"deprecated","affected_versions":">=2.0.0"}],"env_vars":null,"search_vec":"'2.0.1':29 'activ':34,73 'ago':38 'api':10,15 'apollo':65 'base':45 'browser':82 'built':11,54 'built-in':53 'cach':71 'client':3,7,88 'cross':22 'cross-environ':21 'current':25 'environ':23 'error':56 'execut':48 'fetch':14,19 'fledg':87 'full':86 'full-fledg':85 'graphql':2,9 'graphql-client':1 'handl':57 'highlight':62 'http':6 'includ':59 'integr':78 'interfac':46 'isomorph':18 'isomorphic-fetch':17 'javascript':91 'lack':69 'last':35 'lightweight':5 'locat':61 'mainten':74 'minim':77 'mutat':51 'node.js':80 'overkil':90 'promis':44 'promise-bas':43 'provid':40 'queri':49,60 'recent':32 'relay':67 'releas':33 'simpl':42 'simpler':63 'stabl':26 'subscript':70 'suitabl':75 'support':24 'updat':36 'version':27 'year':37","created_at":"2026-06-07T16:53:26.946589+00:00","updated_at":"2026-06-07T16:53:26.946589+00:00","problems":[{"fix":"Use 'import client from 'graphql-client'' or 'const client = require('graphql-client')'.","cause":"Importing named exports instead of default; or using ES6 import incorrectly.","error":"TypeError: client is not a function"},{"fix":"Add .catch(err => console.error(err.message)) or wrap in try/catch.","cause":"Missing catch handler on query/mutate call.","error":"Unhandled Promise Rejection: GraphQLError"},{"fix":"Install isomorphic-fetch or cross-fetch and import it before graphql-client.","cause":"Running in an environment without fetch (e.g., older Node.js) and isomorphic-fetch not installed.","error":"fetch is not defined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/nordsimon/graphql-client#readme","github":"https://github.com/nordsimon/graphql-client","docs":null,"changelog":null,"pypi":null,"npm":"graphql-client","openapi_spec":null,"status_page":null,"smithery":null,"categories":["api","development"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}