@graphql-tools/delegate 8.4.0-alpha-4c17bf82.0 → 8.4.1-alpha-16b9e69f.0

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.
Files changed (3) hide show
  1. package/index.js +3 -7
  2. package/index.mjs +5 -9
  3. package/package.json +4 -4
package/index.js CHANGED
@@ -1194,11 +1194,7 @@ function delegateRequest(options) {
1194
1194
  }
1195
1195
  function getDelegationContext({ request, schema, fieldName, returnType, args, info, transforms = [], transformedSchema, skipTypeMerging = false, }) {
1196
1196
  var _a, _b, _c, _d;
1197
- const { context, operationName, document } = request;
1198
- const operationDefinition = graphql.getOperationAST(document, operationName);
1199
- if (operationDefinition == null) {
1200
- throw new Error('Cannot infer main operation from the provided document.');
1201
- }
1197
+ const operationDefinition = utils.getOperationASTFromRequest(request);
1202
1198
  let targetFieldName;
1203
1199
  if (fieldName == null) {
1204
1200
  targetFieldName = operationDefinition.selectionSet.selections[0].name.value;
@@ -1218,7 +1214,7 @@ function getDelegationContext({ request, schema, fieldName, returnType, args, in
1218
1214
  operation,
1219
1215
  fieldName: targetFieldName,
1220
1216
  args,
1221
- context,
1217
+ context: request.context,
1222
1218
  info,
1223
1219
  returnType: (_c = returnType !== null && returnType !== void 0 ? returnType : info === null || info === void 0 ? void 0 : info.returnType) !== null && _c !== void 0 ? _c : getDelegationReturnType(targetSchema, operation, targetFieldName),
1224
1220
  transforms: subschemaOrSubschemaConfig.transforms != null
@@ -1235,7 +1231,7 @@ function getDelegationContext({ request, schema, fieldName, returnType, args, in
1235
1231
  operation,
1236
1232
  fieldName: targetFieldName,
1237
1233
  args,
1238
- context,
1234
+ context: request.context,
1239
1235
  info,
1240
1236
  returnType: (_d = returnType !== null && returnType !== void 0 ? returnType : info === null || info === void 0 ? void 0 : info.returnType) !== null && _d !== void 0 ? _d : getDelegationReturnType(subschemaOrSubschemaConfig, operation, targetFieldName),
1241
1237
  transforms,
package/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { Kind, isAbstractType, isInterfaceType, TypeInfo, visit, visitWithTypeInfo, getNamedType, isObjectType, versionInfo, TypeNameMetaFieldDef, responsePathAsArray, GraphQLError, locatedError, getNullableType, isCompositeType, isListType, typeFromAST, defaultFieldResolver, getOperationAST, validate, subscribe, execute } from 'graphql';
2
- import { memoize2, implementsAbstractType, getRootTypeNames, getDefinedRootType, createVariableNameGenerator, updateArgument, serializeInputValue, inspect, collectFields, relocatedError, AggregateError, getResponseKeyFromInfo, isAsyncIterable, mapAsyncIterator, memoize1, getOperationASTFromRequest } from '@graphql-tools/utils';
1
+ import { Kind, isAbstractType, isInterfaceType, TypeInfo, visit, visitWithTypeInfo, getNamedType, isObjectType, versionInfo, TypeNameMetaFieldDef, responsePathAsArray, GraphQLError, locatedError, getNullableType, isCompositeType, isListType, typeFromAST, defaultFieldResolver, validate, subscribe, execute } from 'graphql';
2
+ import { memoize2, implementsAbstractType, getRootTypeNames, getDefinedRootType, createVariableNameGenerator, updateArgument, serializeInputValue, inspect, collectFields, relocatedError, AggregateError, getResponseKeyFromInfo, isAsyncIterable, mapAsyncIterator, getOperationASTFromRequest, memoize1 } from '@graphql-tools/utils';
3
3
  import { ValueOrPromise } from 'value-or-promise';
4
4
  import { getBatchingExecutor } from '@graphql-tools/batch-execute';
5
5
 
@@ -1190,11 +1190,7 @@ function delegateRequest(options) {
1190
1190
  }
1191
1191
  function getDelegationContext({ request, schema, fieldName, returnType, args, info, transforms = [], transformedSchema, skipTypeMerging = false, }) {
1192
1192
  var _a, _b, _c, _d;
1193
- const { context, operationName, document } = request;
1194
- const operationDefinition = getOperationAST(document, operationName);
1195
- if (operationDefinition == null) {
1196
- throw new Error('Cannot infer main operation from the provided document.');
1197
- }
1193
+ const operationDefinition = getOperationASTFromRequest(request);
1198
1194
  let targetFieldName;
1199
1195
  if (fieldName == null) {
1200
1196
  targetFieldName = operationDefinition.selectionSet.selections[0].name.value;
@@ -1214,7 +1210,7 @@ function getDelegationContext({ request, schema, fieldName, returnType, args, in
1214
1210
  operation,
1215
1211
  fieldName: targetFieldName,
1216
1212
  args,
1217
- context,
1213
+ context: request.context,
1218
1214
  info,
1219
1215
  returnType: (_c = returnType !== null && returnType !== void 0 ? returnType : info === null || info === void 0 ? void 0 : info.returnType) !== null && _c !== void 0 ? _c : getDelegationReturnType(targetSchema, operation, targetFieldName),
1220
1216
  transforms: subschemaOrSubschemaConfig.transforms != null
@@ -1231,7 +1227,7 @@ function getDelegationContext({ request, schema, fieldName, returnType, args, in
1231
1227
  operation,
1232
1228
  fieldName: targetFieldName,
1233
1229
  args,
1234
- context,
1230
+ context: request.context,
1235
1231
  info,
1236
1232
  returnType: (_d = returnType !== null && returnType !== void 0 ? returnType : info === null || info === void 0 ? void 0 : info.returnType) !== null && _d !== void 0 ? _d : getDelegationReturnType(subschemaOrSubschemaConfig, operation, targetFieldName),
1237
1233
  transforms,
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@graphql-tools/delegate",
3
- "version": "8.4.0-alpha-4c17bf82.0",
3
+ "version": "8.4.1-alpha-16b9e69f.0",
4
4
  "description": "A set of utils for faster development of GraphQL tools",
5
5
  "sideEffects": false,
6
6
  "peerDependencies": {
7
7
  "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
8
8
  },
9
9
  "dependencies": {
10
- "@graphql-tools/batch-execute": "8.3.0-alpha-4c17bf82.0",
11
- "@graphql-tools/schema": "8.3.1-alpha-4c17bf82.0",
12
- "@graphql-tools/utils": "8.5.0-alpha-4c17bf82.0",
10
+ "@graphql-tools/batch-execute": "8.3.1-alpha-16b9e69f.0",
11
+ "@graphql-tools/schema": "8.3.1-alpha-16b9e69f.0",
12
+ "@graphql-tools/utils": "8.6.0-alpha-16b9e69f.0",
13
13
  "dataloader": "2.0.0",
14
14
  "tslib": "~2.3.0",
15
15
  "value-or-promise": "1.0.11"