37 lines
1.4 KiB
TypeScript
37 lines
1.4 KiB
TypeScript
import { ExecutionParams } from './types';
|
|
/**
|
|
* Merge multiple queries into a single query in such a way that query results
|
|
* can be split and transformed as if they were obtained by running original queries.
|
|
*
|
|
* Merging algorithm involves several transformations:
|
|
* 1. Replace top-level fragment spreads with inline fragments (... on Query {})
|
|
* 2. Add unique aliases to all top-level query fields (including those on inline fragments)
|
|
* 3. Prefix all variable definitions and variable usages
|
|
* 4. Prefix names (and spreads) of fragments
|
|
*
|
|
* i.e transform:
|
|
* [
|
|
* `query Foo($id: ID!) { foo, bar(id: $id), ...FooQuery }
|
|
* fragment FooQuery on Query { baz }`,
|
|
*
|
|
* `query Bar($id: ID!) { foo: baz, bar(id: $id), ... on Query { baz } }`
|
|
* ]
|
|
* to:
|
|
* query (
|
|
* $graphqlTools1_id: ID!
|
|
* $graphqlTools2_id: ID!
|
|
* ) {
|
|
* graphqlTools1_foo: foo,
|
|
* graphqlTools1_bar: bar(id: $graphqlTools1_id)
|
|
* ... on Query {
|
|
* graphqlTools1__baz: baz
|
|
* }
|
|
* graphqlTools1__foo: baz
|
|
* graphqlTools1__bar: bar(id: $graphqlTools1__id)
|
|
* ... on Query {
|
|
* graphqlTools1__baz: baz
|
|
* }
|
|
* }
|
|
*/
|
|
export declare function mergeExecutionParams(execs: Array<ExecutionParams>, extensionsReducer: (mergedExtensions: Record<string, any>, executionParams: ExecutionParams) => Record<string, any>): ExecutionParams;
|