A utility to combine multiple GraphQL query or mutation documents into a single document, with support for variable merging and aliasing. Current stable version is 1.2.4, released on npm. It targets Hasura-like servers that benefit from batched mutations in a single transaction, and it works with GraphQL.js v15 or v16. Unlike simple string concatenation, it properly merges arguments, variables, and top-level selections. It also supports adding multiple instances of the same query/mutation with index aliasing via addN. Ships TypeScript type definitions.
npm install graphql-combine-queryNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates a combined query document by merging two separate queries with their variables, demonstrating .add() usage.
Install graphql@^15.1.0 or ^16.0.0 alongside this package.
Ensure variable names do not end with '_0', '_1', etc., or rename them after combining.
Use the combined document as a single query/mutation.
Avoid using fragments, or convert them to inline fragments manually before combining.
Install graphql: npm install graphql
Use import combineQuery from 'graphql-combine-query'
Use require('graphql-combine-query').default or switch to ES module import.