@graphql-tools/utils 8.5.0-alpha-4c17bf82.0 → 8.5.1
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/getOperationASTFromRequest.d.ts +1 -1
- package/index.js +12 -12
- package/index.mjs +13 -13
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ExecutionRequest } from '.';
|
|
2
1
|
import { DocumentNode, OperationDefinitionNode } from 'graphql';
|
|
2
|
+
import { ExecutionRequest } from './Interfaces';
|
|
3
3
|
export declare function getOperationASTFromDocument(documentNode: DocumentNode, operationName?: string): OperationDefinitionNode;
|
|
4
4
|
export declare const getOperationASTFromRequest: (request: ExecutionRequest) => OperationDefinitionNode;
|
package/index.js
CHANGED
|
@@ -3829,6 +3829,17 @@ function observableToAsyncIterable(observable) {
|
|
|
3829
3829
|
};
|
|
3830
3830
|
}
|
|
3831
3831
|
|
|
3832
|
+
function getOperationASTFromDocument(documentNode, operationName) {
|
|
3833
|
+
const doc = graphql.getOperationAST(documentNode, operationName);
|
|
3834
|
+
if (!doc) {
|
|
3835
|
+
throw new Error(`Cannot infer operation ${operationName || ''}`);
|
|
3836
|
+
}
|
|
3837
|
+
return doc;
|
|
3838
|
+
}
|
|
3839
|
+
const getOperationASTFromRequest = memoize1(function getOperationASTFromRequest(request) {
|
|
3840
|
+
return getOperationASTFromDocument(request.document, request.operationName);
|
|
3841
|
+
});
|
|
3842
|
+
|
|
3832
3843
|
// Taken from GraphQL-JS v16 for backwards compat
|
|
3833
3844
|
function collectFields(schema, fragments, variableValues, runtimeType, selectionSet, fields, visitedFragmentNames) {
|
|
3834
3845
|
for (const selection of selectionSet.selections) {
|
|
@@ -3958,7 +3969,7 @@ function visitResult(result, request, schema, resultVisitorMap, errorVisitorMap)
|
|
|
3958
3969
|
const data = result.data;
|
|
3959
3970
|
const errors = result.errors;
|
|
3960
3971
|
const visitingErrors = errors != null && errorVisitorMap != null;
|
|
3961
|
-
const operationDocumentNode =
|
|
3972
|
+
const operationDocumentNode = getOperationASTFromRequest(request);
|
|
3962
3973
|
if (data != null && operationDocumentNode != null) {
|
|
3963
3974
|
result.data = visitRoot(data, operationDocumentNode, schema, fragments, variableValues, resultVisitorMap, visitingErrors ? errors : undefined, errorInfo);
|
|
3964
3975
|
}
|
|
@@ -4182,17 +4193,6 @@ function fixSchemaAst(schema, options) {
|
|
|
4182
4193
|
return schema;
|
|
4183
4194
|
}
|
|
4184
4195
|
|
|
4185
|
-
function getOperationASTFromDocument(documentNode, operationName) {
|
|
4186
|
-
const doc = graphql.getOperationAST(documentNode, operationName);
|
|
4187
|
-
if (!doc) {
|
|
4188
|
-
throw new Error(`Cannot infer operation ${operationName || ''}`);
|
|
4189
|
-
}
|
|
4190
|
-
return doc;
|
|
4191
|
-
}
|
|
4192
|
-
const getOperationASTFromRequest = memoize1(function getOperationASTFromRequest(request) {
|
|
4193
|
-
return getOperationASTFromDocument(request.document, request.operationName);
|
|
4194
|
-
});
|
|
4195
|
-
|
|
4196
4196
|
exports.addTypes = addTypes;
|
|
4197
4197
|
exports.appendObjectFields = appendObjectFields;
|
|
4198
4198
|
exports.asArray = asArray;
|
package/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { parse, isNonNullType, GraphQLError, Kind, valueFromAST, print, isObjectType, isListType, isSpecifiedDirective, astFromValue, isSpecifiedScalarType, isIntrospectionType, isInterfaceType, isUnionType, isInputObjectType, isEnumType, isScalarType, GraphQLDeprecatedDirective, specifiedRules, concatAST, validate, versionInfo, buildClientSchema, visit, TokenKind, Source, isTypeSystemDefinitionNode, getNamedType, GraphQLString, GraphQLNonNull, GraphQLList, GraphQLID, GraphQLBoolean, GraphQLFloat, GraphQLInt, GraphQLObjectType, GraphQLInterfaceType, GraphQLInputObjectType, GraphQLDirective, GraphQLUnionType, GraphQLEnumType, GraphQLScalarType, isNamedType, getNullableType, isLeafType, GraphQLSchema, isDirective, isCompositeType, doTypesOverlap, getDirectiveValues, GraphQLSkipDirective, GraphQLIncludeDirective, typeFromAST, isAbstractType,
|
|
1
|
+
import { parse, isNonNullType, GraphQLError, Kind, valueFromAST, print, isObjectType, isListType, isSpecifiedDirective, astFromValue, isSpecifiedScalarType, isIntrospectionType, isInterfaceType, isUnionType, isInputObjectType, isEnumType, isScalarType, GraphQLDeprecatedDirective, specifiedRules, concatAST, validate, versionInfo, buildClientSchema, visit, TokenKind, Source, isTypeSystemDefinitionNode, getNamedType, GraphQLString, GraphQLNonNull, GraphQLList, GraphQLID, GraphQLBoolean, GraphQLFloat, GraphQLInt, GraphQLObjectType, GraphQLInterfaceType, GraphQLInputObjectType, GraphQLDirective, GraphQLUnionType, GraphQLEnumType, GraphQLScalarType, isNamedType, getNullableType, isLeafType, GraphQLSchema, isDirective, isCompositeType, doTypesOverlap, getOperationAST, getDirectiveValues, GraphQLSkipDirective, GraphQLIncludeDirective, typeFromAST, isAbstractType, getOperationRootType, TypeNameMetaFieldDef, buildASTSchema } from 'graphql';
|
|
2
2
|
|
|
3
3
|
const asArray = (fns) => (Array.isArray(fns) ? fns : fns ? [fns] : []);
|
|
4
4
|
const invalidDocRegex = /\.[a-z0-9]+$/i;
|
|
@@ -3826,6 +3826,17 @@ function observableToAsyncIterable(observable) {
|
|
|
3826
3826
|
};
|
|
3827
3827
|
}
|
|
3828
3828
|
|
|
3829
|
+
function getOperationASTFromDocument(documentNode, operationName) {
|
|
3830
|
+
const doc = getOperationAST(documentNode, operationName);
|
|
3831
|
+
if (!doc) {
|
|
3832
|
+
throw new Error(`Cannot infer operation ${operationName || ''}`);
|
|
3833
|
+
}
|
|
3834
|
+
return doc;
|
|
3835
|
+
}
|
|
3836
|
+
const getOperationASTFromRequest = memoize1(function getOperationASTFromRequest(request) {
|
|
3837
|
+
return getOperationASTFromDocument(request.document, request.operationName);
|
|
3838
|
+
});
|
|
3839
|
+
|
|
3829
3840
|
// Taken from GraphQL-JS v16 for backwards compat
|
|
3830
3841
|
function collectFields(schema, fragments, variableValues, runtimeType, selectionSet, fields, visitedFragmentNames) {
|
|
3831
3842
|
for (const selection of selectionSet.selections) {
|
|
@@ -3955,7 +3966,7 @@ function visitResult(result, request, schema, resultVisitorMap, errorVisitorMap)
|
|
|
3955
3966
|
const data = result.data;
|
|
3956
3967
|
const errors = result.errors;
|
|
3957
3968
|
const visitingErrors = errors != null && errorVisitorMap != null;
|
|
3958
|
-
const operationDocumentNode =
|
|
3969
|
+
const operationDocumentNode = getOperationASTFromRequest(request);
|
|
3959
3970
|
if (data != null && operationDocumentNode != null) {
|
|
3960
3971
|
result.data = visitRoot(data, operationDocumentNode, schema, fragments, variableValues, resultVisitorMap, visitingErrors ? errors : undefined, errorInfo);
|
|
3961
3972
|
}
|
|
@@ -4179,15 +4190,4 @@ function fixSchemaAst(schema, options) {
|
|
|
4179
4190
|
return schema;
|
|
4180
4191
|
}
|
|
4181
4192
|
|
|
4182
|
-
function getOperationASTFromDocument(documentNode, operationName) {
|
|
4183
|
-
const doc = getOperationAST(documentNode, operationName);
|
|
4184
|
-
if (!doc) {
|
|
4185
|
-
throw new Error(`Cannot infer operation ${operationName || ''}`);
|
|
4186
|
-
}
|
|
4187
|
-
return doc;
|
|
4188
|
-
}
|
|
4189
|
-
const getOperationASTFromRequest = memoize1(function getOperationASTFromRequest(request) {
|
|
4190
|
-
return getOperationASTFromDocument(request.document, request.operationName);
|
|
4191
|
-
});
|
|
4192
|
-
|
|
4193
4193
|
export { AggregateErrorImpl as AggregateError, MapperKind, addTypes, appendObjectFields, asArray, assertSome, astFromArg, astFromDirective, astFromEnumType, astFromEnumValue, astFromField, astFromInputField, astFromInputObjectType, astFromInterfaceType, astFromObjectType, astFromScalarType, astFromSchema, astFromUnionType, astFromValueUntyped, buildOperationNodeForField, checkValidationErrors, collectComment, collectFields, collectSubFields, compareNodes, compareStrings, correctASTNodes, createDefaultRules, createNamedStub, createStub, createVariableNameGenerator, dedentBlockStringValue, filterSchema, fixSchemaAst, forEachDefaultValue, forEachField, getArgumentValues, getBlockStringIndentation, getBuiltInForStub, getComment, getDefinedRootType, getDeprecatableDirectiveNodes, getDescription, getDirective, getDirectiveInExtensions, getDirectiveNodes, getDirectives, getDirectivesInExtensions, getDocumentNodeFromSchema, getFieldsWithDirectives, getImplementingTypes, getLeadingCommentBlock, getOperationASTFromDocument, getOperationASTFromRequest, getResolversFromSchema, getResponseKeyFromInfo, getRootTypeMap, getRootTypeNames, getRootTypes, healSchema, healTypes, implementsAbstractType, inspect, isAsyncIterable, isDescribable, isDocumentNode, isDocumentString, isNamedStub, isSome, isValidPath, makeDeprecatedDirective, makeDirectiveNode, makeDirectiveNodes, mapAsyncIterator, mapSchema, memoize1, memoize2, memoize2of4, memoize3, memoize4, memoize5, mergeDeep, modifyObjectFields, nodeToString, observableToAsyncIterable, parseGraphQLJSON, parseGraphQLSDL, parseInputValue, parseInputValueLiteral, parseSelectionSet, printComment, printSchemaWithDirectives, printWithComments, pruneSchema, pushComment, relocatedError, removeObjectFields, renameType, resetComments, rewireTypes, selectObjectFields, serializeInputValue, transformCommentsToDescriptions, transformInputValue, updateArgument, validateGraphQlDocuments, valueMatchesCriteria, visitData, visitErrors, visitResult, withCancel };
|