@graphql-tools/utils 8.13.0 → 8.14.0-alpha-20221029153041-68044ec1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cjs/collectFields.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.collectSubFields = exports.collectFields = void 0;
|
|
3
|
+
exports.collectSubFields = exports.getFieldEntryKey = exports.doesFragmentConditionMatch = exports.shouldIncludeNode = exports.collectFields = void 0;
|
|
4
4
|
const memoize_js_1 = require("./memoize.js");
|
|
5
5
|
const graphql_1 = require("graphql");
|
|
6
6
|
// Taken from GraphQL-JS v16 for backwards compat
|
|
@@ -62,6 +62,7 @@ function shouldIncludeNode(variableValues, node) {
|
|
|
62
62
|
}
|
|
63
63
|
return true;
|
|
64
64
|
}
|
|
65
|
+
exports.shouldIncludeNode = shouldIncludeNode;
|
|
65
66
|
/**
|
|
66
67
|
* Determines if a fragment is applicable to the given type.
|
|
67
68
|
*/
|
|
@@ -80,12 +81,14 @@ function doesFragmentConditionMatch(schema, fragment, type) {
|
|
|
80
81
|
}
|
|
81
82
|
return false;
|
|
82
83
|
}
|
|
84
|
+
exports.doesFragmentConditionMatch = doesFragmentConditionMatch;
|
|
83
85
|
/**
|
|
84
86
|
* Implements the logic to compute the key of a given field's entry
|
|
85
87
|
*/
|
|
86
88
|
function getFieldEntryKey(node) {
|
|
87
89
|
return node.alias ? node.alias.value : node.name.value;
|
|
88
90
|
}
|
|
91
|
+
exports.getFieldEntryKey = getFieldEntryKey;
|
|
89
92
|
exports.collectSubFields = (0, memoize_js_1.memoize5)(function collectSubFields(schema, fragments, variableValues, type, fieldNodes) {
|
|
90
93
|
const subFieldNodes = new Map();
|
|
91
94
|
const visitedFragmentNames = new Set();
|
package/esm/collectFields.js
CHANGED
|
@@ -47,7 +47,7 @@ export function collectFields(schema, fragments, variableValues, runtimeType, se
|
|
|
47
47
|
* Determines if a field should be included based on the `@include` and `@skip`
|
|
48
48
|
* directives, where `@skip` has higher precedence than `@include`.
|
|
49
49
|
*/
|
|
50
|
-
function shouldIncludeNode(variableValues, node) {
|
|
50
|
+
export function shouldIncludeNode(variableValues, node) {
|
|
51
51
|
const skip = getDirectiveValues(GraphQLSkipDirective, node, variableValues);
|
|
52
52
|
if ((skip === null || skip === void 0 ? void 0 : skip['if']) === true) {
|
|
53
53
|
return false;
|
|
@@ -61,7 +61,7 @@ function shouldIncludeNode(variableValues, node) {
|
|
|
61
61
|
/**
|
|
62
62
|
* Determines if a fragment is applicable to the given type.
|
|
63
63
|
*/
|
|
64
|
-
function doesFragmentConditionMatch(schema, fragment, type) {
|
|
64
|
+
export function doesFragmentConditionMatch(schema, fragment, type) {
|
|
65
65
|
const typeConditionNode = fragment.typeCondition;
|
|
66
66
|
if (!typeConditionNode) {
|
|
67
67
|
return true;
|
|
@@ -79,7 +79,7 @@ function doesFragmentConditionMatch(schema, fragment, type) {
|
|
|
79
79
|
/**
|
|
80
80
|
* Implements the logic to compute the key of a given field's entry
|
|
81
81
|
*/
|
|
82
|
-
function getFieldEntryKey(node) {
|
|
82
|
+
export function getFieldEntryKey(node) {
|
|
83
83
|
return node.alias ? node.alias.value : node.name.value;
|
|
84
84
|
}
|
|
85
85
|
export const collectSubFields = memoize5(function collectSubFields(schema, fragments, variableValues, type, fieldNodes) {
|
package/package.json
CHANGED
package/typings/Interfaces.d.cts
CHANGED
|
@@ -4,7 +4,9 @@ import { GraphQLSchema, GraphQLField, GraphQLInputType, GraphQLNamedType, GraphQ
|
|
|
4
4
|
*
|
|
5
5
|
* - `errors` is included when any errors occurred as a non-empty array.
|
|
6
6
|
* - `data` is the result of a successful execution of the query.
|
|
7
|
+
* - `hasNext` is true if a future payload is expected.
|
|
7
8
|
* - `extensions` is reserved for adding non-standard properties.
|
|
9
|
+
* - `incremental` is a list of the results from defer/stream directives.
|
|
8
10
|
*/
|
|
9
11
|
export interface ExecutionResult<TData = any, TExtensions = any> {
|
|
10
12
|
errors?: ReadonlyArray<GraphQLError>;
|
package/typings/Interfaces.d.ts
CHANGED
|
@@ -4,7 +4,9 @@ import { GraphQLSchema, GraphQLField, GraphQLInputType, GraphQLNamedType, GraphQ
|
|
|
4
4
|
*
|
|
5
5
|
* - `errors` is included when any errors occurred as a non-empty array.
|
|
6
6
|
* - `data` is the result of a successful execution of the query.
|
|
7
|
+
* - `hasNext` is true if a future payload is expected.
|
|
7
8
|
* - `extensions` is reserved for adding non-standard properties.
|
|
9
|
+
* - `incremental` is a list of the results from defer/stream directives.
|
|
8
10
|
*/
|
|
9
11
|
export interface ExecutionResult<TData = any, TExtensions = any> {
|
|
10
12
|
errors?: ReadonlyArray<GraphQLError>;
|
|
@@ -1,5 +1,18 @@
|
|
|
1
|
-
import { GraphQLSchema, FragmentDefinitionNode, GraphQLObjectType, SelectionSetNode, FieldNode } from 'graphql';
|
|
1
|
+
import { GraphQLSchema, FragmentDefinitionNode, GraphQLObjectType, SelectionSetNode, FieldNode, FragmentSpreadNode, InlineFragmentNode } from 'graphql';
|
|
2
2
|
export declare function collectFields(schema: GraphQLSchema, fragments: Record<string, FragmentDefinitionNode>, variableValues: {
|
|
3
3
|
[variable: string]: unknown;
|
|
4
4
|
}, runtimeType: GraphQLObjectType, selectionSet: SelectionSetNode, fields?: Map<string, Array<FieldNode>>, visitedFragmentNames?: Set<string>): Map<string, Array<FieldNode>>;
|
|
5
|
+
/**
|
|
6
|
+
* Determines if a field should be included based on the `@include` and `@skip`
|
|
7
|
+
* directives, where `@skip` has higher precedence than `@include`.
|
|
8
|
+
*/
|
|
9
|
+
export declare function shouldIncludeNode(variableValues: any, node: FragmentSpreadNode | FieldNode | InlineFragmentNode): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Determines if a fragment is applicable to the given type.
|
|
12
|
+
*/
|
|
13
|
+
export declare function doesFragmentConditionMatch(schema: GraphQLSchema, fragment: FragmentDefinitionNode | InlineFragmentNode, type: GraphQLObjectType): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Implements the logic to compute the key of a given field's entry
|
|
16
|
+
*/
|
|
17
|
+
export declare function getFieldEntryKey(node: FieldNode): string;
|
|
5
18
|
export declare const collectSubFields: (schema: GraphQLSchema, fragments: Record<string, FragmentDefinitionNode>, variableValues: Record<string, any>, type: GraphQLObjectType, fieldNodes: Array<FieldNode>) => Map<string, Array<FieldNode>>;
|
|
@@ -1,5 +1,18 @@
|
|
|
1
|
-
import { GraphQLSchema, FragmentDefinitionNode, GraphQLObjectType, SelectionSetNode, FieldNode } from 'graphql';
|
|
1
|
+
import { GraphQLSchema, FragmentDefinitionNode, GraphQLObjectType, SelectionSetNode, FieldNode, FragmentSpreadNode, InlineFragmentNode } from 'graphql';
|
|
2
2
|
export declare function collectFields(schema: GraphQLSchema, fragments: Record<string, FragmentDefinitionNode>, variableValues: {
|
|
3
3
|
[variable: string]: unknown;
|
|
4
4
|
}, runtimeType: GraphQLObjectType, selectionSet: SelectionSetNode, fields?: Map<string, Array<FieldNode>>, visitedFragmentNames?: Set<string>): Map<string, Array<FieldNode>>;
|
|
5
|
+
/**
|
|
6
|
+
* Determines if a field should be included based on the `@include` and `@skip`
|
|
7
|
+
* directives, where `@skip` has higher precedence than `@include`.
|
|
8
|
+
*/
|
|
9
|
+
export declare function shouldIncludeNode(variableValues: any, node: FragmentSpreadNode | FieldNode | InlineFragmentNode): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Determines if a fragment is applicable to the given type.
|
|
12
|
+
*/
|
|
13
|
+
export declare function doesFragmentConditionMatch(schema: GraphQLSchema, fragment: FragmentDefinitionNode | InlineFragmentNode, type: GraphQLObjectType): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Implements the logic to compute the key of a given field's entry
|
|
16
|
+
*/
|
|
17
|
+
export declare function getFieldEntryKey(node: FieldNode): string;
|
|
5
18
|
export declare const collectSubFields: (schema: GraphQLSchema, fragments: Record<string, FragmentDefinitionNode>, variableValues: Record<string, any>, type: GraphQLObjectType, fieldNodes: Array<FieldNode>) => Map<string, Array<FieldNode>>;
|