A simple JavaScript/TypeScript utility for building GraphQL queries, mutations, and subscriptions from plain JSON objects. Current stable version is 3.8.0, released under MIT license. Enables programmatic construction of GraphQL operations without string concatenation or template literals, supporting variables with required/type/list metadata, aliases, nested fields, operation names, and custom adapters. Ships TypeScript definitions and is compatible with both ESM and CommonJS. Minimal footprint with no runtime dependencies, making it suitable for server-side and client-side usage. Compared to alternatives like graphql-tag, it offers a simpler API focused on object composition rather than template parsing.
npm install gql-query-builderNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to generate GraphQL query and mutation strings using JavaScript objects with variables and fields.
Use { variableName: { value: actualValue, required: true, type: 'String', list: false, name: 'argName' } } instead of { variableName: actualValue }.Change import { query } from 'gql-query-builder' or import * as gql from 'gql-query-builder'. If using require, use const { query } = require('gql-query-builder').Stick to default adapters unless you've implemented a custom one. Avoid relying on adapter feature for production.
Use { operation: { name: 'op', alias: 'uniqueAlias' }, ... } for each operation in the array.Always use proper GraphQL type names with correct casing (e.g., 'String' not 'string', 'Int' not 'int').
Use import { query } from 'gql-query-builder' or import * as gql from 'gql-query-builder' then gql.query(...).Ensure variables object includes both 'value' and 'required' for each variable you want to be passed; the operation string will automatically add the variable declaration.
Install with npm install gql-query-builder and ensure tsconfig.json includes 'node_modules' in typeRoots or the package's types are picked up automatically.
Ensure you are using the default import correctly: import gql from 'gql-query-builder' and then call gql.query(options).
No dependency data recorded yet.