@graphql-tools/wrap 7.0.6-alpha-1a132cb3.0 → 7.0.8

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/es5/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@graphql-tools/wrap/es5",
3
- "version": "7.0.6-alpha-1a132cb3.0",
3
+ "version": "7.0.8",
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"
8
8
  },
9
9
  "dependencies": {
10
- "@graphql-tools/delegate": "7.1.3-alpha-1a132cb3.0",
11
- "@graphql-tools/schema": "7.1.4-alpha-1a132cb3.0",
12
- "@graphql-tools/utils": "^7.2.1",
10
+ "@graphql-tools/delegate": "^7.1.5",
11
+ "@graphql-tools/schema": "^7.1.5",
12
+ "@graphql-tools/utils": "^7.8.1",
13
13
  "tslib": "~2.2.0",
14
- "value-or-promise": "~1.0.5"
14
+ "value-or-promise": "1.0.6"
15
15
  },
16
16
  "repository": {
17
17
  "type": "git",
@@ -1,8 +1,8 @@
1
1
  import { SelectionSetNode, FragmentDefinitionNode } from 'graphql';
2
2
  import { Request, ExecutionResult } from '@graphql-tools/utils';
3
3
  import { Transform, DelegationContext } from '@graphql-tools/delegate';
4
- export declare type QueryTransformer = (selectionSet: SelectionSetNode, fragments: Record<string, FragmentDefinitionNode>) => SelectionSetNode;
5
- export declare type ResultTransformer = (result: any) => any;
4
+ export declare type QueryTransformer = (selectionSet: SelectionSetNode, fragments: Record<string, FragmentDefinitionNode>, delegationContext: DelegationContext, transformationContext: Record<string, any>) => SelectionSetNode;
5
+ export declare type ResultTransformer = (result: any, delegationContext: DelegationContext, transformationContext: Record<string, any>) => any;
6
6
  export declare type ErrorPathTransformer = (path: ReadonlyArray<string | number>) => Array<string | number>;
7
7
  export default class TransformQuery implements Transform {
8
8
  private readonly path;
@@ -17,8 +17,8 @@ export default class TransformQuery implements Transform {
17
17
  errorPathTransformer?: ErrorPathTransformer;
18
18
  fragments?: Record<string, FragmentDefinitionNode>;
19
19
  });
20
- transformRequest(originalRequest: Request, _delegationContext: DelegationContext, _transformationContext: Record<string, any>): Request;
21
- transformResult(originalResult: ExecutionResult, _delegationContext: DelegationContext, _transformationContext: Record<string, any>): ExecutionResult;
20
+ transformRequest(originalRequest: Request, delegationContext: DelegationContext, transformationContext: Record<string, any>): Request;
21
+ transformResult(originalResult: ExecutionResult, delegationContext: DelegationContext, transformationContext: Record<string, any>): ExecutionResult;
22
22
  private transformData;
23
23
  private transformErrors;
24
24
  }
package/index.cjs.js CHANGED
@@ -890,7 +890,7 @@ class TransformQuery {
890
890
  this.errorPathTransformer = errorPathTransformer;
891
891
  this.fragments = fragments;
892
892
  }
893
- transformRequest(originalRequest, _delegationContext, _transformationContext) {
893
+ transformRequest(originalRequest, delegationContext, transformationContext) {
894
894
  const pathLength = this.path.length;
895
895
  let index = 0;
896
896
  const document = graphql.visit(originalRequest.document, {
@@ -901,7 +901,7 @@ class TransformQuery {
901
901
  }
902
902
  index++;
903
903
  if (index === pathLength) {
904
- const selectionSet = this.queryTransformer(node.selectionSet, this.fragments);
904
+ const selectionSet = this.queryTransformer(node.selectionSet, this.fragments, delegationContext, transformationContext);
905
905
  return {
906
906
  ...node,
907
907
  selectionSet,
@@ -918,15 +918,15 @@ class TransformQuery {
918
918
  document,
919
919
  };
920
920
  }
921
- transformResult(originalResult, _delegationContext, _transformationContext) {
922
- const data = this.transformData(originalResult.data);
921
+ transformResult(originalResult, delegationContext, transformationContext) {
922
+ const data = this.transformData(originalResult.data, delegationContext, transformationContext);
923
923
  const errors = originalResult.errors;
924
924
  return {
925
925
  data,
926
926
  errors: errors != null ? this.transformErrors(errors) : undefined,
927
927
  };
928
928
  }
929
- transformData(data) {
929
+ transformData(data, delegationContext, transformationContext) {
930
930
  const leafIndex = this.path.length - 1;
931
931
  let index = 0;
932
932
  let newData = data;
@@ -942,7 +942,7 @@ class TransformQuery {
942
942
  index++;
943
943
  next = this.path[index];
944
944
  }
945
- newData[next] = this.resultTransformer(newData[next]);
945
+ newData[next] = this.resultTransformer(newData[next], delegationContext, transformationContext);
946
946
  }
947
947
  return newData;
948
948
  }