{"id":47867,"library":"graphql-fetch-optimizer","title":"graphql-fetch-optimizer","description":"Drop-in replacement for nodejs fetch that optimizes GraphQL requests by automatically handling pagination for root-level fields with `first: \"auto\"`. Version 1.0.11, maintained infrequently. Unlike generic fetch wrappers, it specifically merges paginated results transparently, supports sequential fetch mode (useful for underpowered CMS backends), and includes debug capabilities. Works only with schemas providing `nodes` and `pageInfo { hasNextPage, endCursor }`.","status":"active","version":"1.0.11","language":"javascript","source_language":"en","source_url":"https://github.com/internet2000/graphql-fetch-optimizer","tags":["javascript"],"install":[{"cmd":"npm install graphql-fetch-optimizer","lang":"bash","label":"npm"},{"cmd":"yarn add graphql-fetch-optimizer","lang":"bash","label":"yarn"},{"cmd":"pnpm add graphql-fetch-optimizer","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Package is ESM-only; CJS require will error.","wrong":"const { createPatchedFetch } = require('graphql-fetch-optimizer')","symbol":"createPatchedFetch","correct":"import { createPatchedFetch } from 'graphql-fetch-optimizer'"},{"note":"This is a separate export from a subpath; must include '/paginate.js'.","wrong":"import { fetchRootPaginatedFields } from 'graphql-fetch-optimizer'","symbol":"fetchRootPaginatedFields","correct":"import { fetchRootPaginatedFields } from 'graphql-fetch-optimizer/paginate.js'"},{"note":"Default export is not provided; only named exports. This pattern will break.","wrong":"const gqlFetch = require('graphql-fetch-optimizer')","symbol":"default import","correct":"import gqlFetch from 'graphql-fetch-optimizer'"}],"quickstart":{"code":"import { createPatchedFetch } from 'graphql-fetch-optimizer'\nconst patchedFetch = createPatchedFetch(fetch)\nconst query = `{ menus(first: \"auto\") { nodes { id label } pageInfo { hasNextPage endCursor } } }`\nconst res = await patchedFetch('https://api.example.com/graphql', {\n  method: 'POST',\n  headers: { 'Content-Type': 'application/json' },\n  body: JSON.stringify({ query })\n})\nconst json = await res.json()\nconsole.log(json.data.menus.nodes)","lang":"javascript","description":"Patches fetch to automatically paginate GraphQL root fields marked with first: 'auto'."},"warnings":[{"fix":"Define $varUsage variable before using it.","message":"$varUsage is used in a context where it may not be defined","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure your query uses first: 'auto' on root fields; nested pagination is not supported.","message":"Only root-level fields with first: 'auto' are paginated","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use import instead of require, or ensure your project is configured for ESM.","message":"Package is ESM-only since v1.0.0; CommonJS require will fail","severity":"breaking","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'1.0.11':29 'auto':27 'automat':17 'backend':50 'capabl':54 'cms':49 'debug':53 'drop':6 'drop-in':5 'endcursor':64 'fetch':3,11,34,44 'field':24 'first':26 'generic':33 'graphql':2,14 'graphql-fetch-optim':1 'handl':18 'hasnextpag':63 'includ':52 'infrequ':31 'javascript':65 'level':23 'maintain':30 'merg':38 'mode':45 'node':60 'nodej':10 'optim':4,13 'pageinfo':62 'pagin':19,39 'provid':59 'replac':8 'request':15 'result':40 'root':22 'root-level':21 'schema':58 'sequenti':43 'specif':37 'support':42 'transpar':41 'underpow':48 'unlik':32 'use':46 'version':28 'work':55 'wrapper':35","created_at":"2026-06-07T16:53:43.819233+00:00","updated_at":"2026-06-07T16:53:43.819233+00:00","problems":[{"fix":"Change to import syntax or set { \"type\": \"module\" } in package.json.","cause":"Using require() on an ESM-only package","error":"ERR_REQUIRE_ESM"},{"fix":"Use 'graphql-fetch-optimizer/paginate.js' instead of 'graphql-fetch-optimizer/paginate'.","cause":"Missing '.js' extension in import path","error":"Cannot find module 'graphql-fetch-optimizer/paginate'"},{"fix":"Use import { createPatchedFetch } from 'graphql-fetch-optimizer'.","cause":"Default import when only named export exists","error":"TypeError: createPatchedFetch is not a function"}],"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/internet2000/graphql-fetch-optimizer#readme","github":"https://github.com/internet2000/graphql-fetch-optimizer","docs":null,"changelog":null,"pypi":null,"npm":"graphql-fetch-optimizer","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"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}}