{"id":47820,"library":"graphql-binding","title":"GraphQL Binding","description":"GraphQL binding is a library for creating modular building blocks that embed existing GraphQL APIs into your own GraphQL server. It allows you to turn parts of GraphQL APIs into reusable components, supporting JavaScript, TypeScript, and Flow. Current stable version is 2.5.2, with irregular releases. Key differentiators: enables composition and reuse of GraphQL APIs, integrates with Prisma and other services. Note: the library is in maintenance mode; consider using modern alternatives like graphql-codegen or built-in federation.","status":"maintenance","version":"2.5.2","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/graphcool/graphql-binding","tags":["javascript","typescript"],"install":[{"cmd":"npm install graphql-binding","lang":"bash","label":"npm"},{"cmd":"yarn add graphql-binding","lang":"bash","label":"yarn"},{"cmd":"pnpm add graphql-binding","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM usage requires TypeScript or bundler; CommonJS works but the default export is different.","wrong":"const Binding = require('graphql-binding')","symbol":"Binding","correct":"import { Binding } from 'graphql-binding'"},{"note":"CommonJS default is an object; named import is recommended.","wrong":"const { Binding } = require('graphql-binding')","symbol":"Binding as default","correct":"import Binding from 'graphql-binding'"},{"note":"The CommonJS module exports an object with Binding as a property, not a default export.","wrong":"const Binding = require('graphql-binding').default","symbol":"Binding class","correct":"const { Binding } = require('graphql-binding')"}],"quickstart":{"code":"import { Binding } from 'graphql-binding';\nimport { GraphQLClient } from 'graphql-request';\n\nconst client = new GraphQLClient('https://api.example.com/graphql', {\n  headers: { Authorization: `Bearer ${process.env.API_KEY ?? ''}` },\n});\n\nconst binding = new Binding({\n  schema: `\n    type Query {\n      user(id: ID!): User\n    }\n    type User {\n      id: ID!\n      name: String!\n    }\n  `,\n  fragmentReplacements: {},\n  before: () => console.log('Before query'),\n});\n\n// Usage\nbinding.query.user({ id: '1' }).then(user => console.log(user));\n","lang":"typescript","description":"Creates a binding from a GraphQL schema string and uses it to query a user."},"warnings":[{"fix":"Migrate to graphql-codegen (https://graphql-code-generator.com) or Apollo Federation.","message":"graphql-binding is in maintenance mode and not actively developed. Consider using graphql-codegen or federation.","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"Update constructor to pass schema as string or DocumentNode.","message":"Breaking: In version 2.0, the constructor API changed. The 'schema' parameter now expects a string or DocumentNode, not a GraphQLSchema object.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Update hook signatures to (delegate: DelegateFunction) => void.","message":"Breaking: The 'before' and 'after' hooks no longer receive the query document as second argument. Instead, they receive only the delegate function.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Use const { Binding } = require('graphql-binding');","message":"CommonJS users: require('graphql-binding') returns an object, not the class directly. You must destructure { Binding }.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Use TypeScript and configure bundler to handle .ts files.","message":"If you import using ES modules, ensure you have a bundler that handles TypeScript, as the package ships with TypeScript declarations but expects bundler for ESM.","severity":"gotcha","affected_versions":">=2.0.0"}],"env_vars":null,"search_vec":"'2.5.2':44 'allow':24 'altern':73 'api':17,31,56 'bind':2,4 'block':12 'build':11 'built':80 'built-in':79 'codegen':77 'compon':34 'composit':51 'consid':70 'creat':9 'current':40 'differenti':49 'emb':14 'enabl':50 'exist':15 'feder':82 'flow':39 'graphql':1,3,16,21,30,55,76 'graphql-codegen':75 'integr':57 'irregular':46 'javascript':36,83 'key':48 'librari':7,65 'like':74 'mainten':68 'mode':69 'modern':72 'modular':10 'note':63 'part':28 'prisma':59 'releas':47 'reus':53 'reusabl':33 'server':22 'servic':62 'stabl':41 'support':35 'turn':27 'typescript':37,84 'use':71 'version':42","created_at":"2026-06-07T16:53:28.348317+00:00","updated_at":"2026-06-07T16:53:28.348317+00:00","problems":[{"fix":"Run npm install graphql-binding or yarn add graphql-binding","cause":"Package not installed or incorrect import path.","error":"Cannot find module 'graphql-binding'"},{"fix":"Use const { Binding } = require('graphql-binding'); or import { Binding } from 'graphql-binding';","cause":"Importing incorrectly: using default import when CommonJS is required.","error":"TypeError: graphql_binding_1.Binding is not a constructor"},{"fix":"Ensure you destructure Binding: const { Binding } = require('graphql-binding');","cause":"Passing an object to require and trying to construct the object itself.","error":"Binding is not a constructor"}],"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/graphcool/graphql-binding#readme","github":"ssh://git@github.com/graphcool/graphql-binding","docs":null,"changelog":null,"pypi":null,"npm":"graphql-binding","openapi_spec":null,"status_page":null,"smithery":null,"categories":["api"],"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}}