@graphitation/apollo-react-relay-duct-tape-compiler 1.6.20 → 1.7.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 (42) hide show
  1. package/CHANGELOG.md +12 -2
  2. package/lib/cli.js +106 -144
  3. package/lib/cli.js.map +1 -1
  4. package/lib/cli.mjs +106 -146
  5. package/lib/cli.mjs.map +1 -1
  6. package/lib/compilerTransforms/annotateFragmentReferenceTransform.js +6 -21
  7. package/lib/compilerTransforms/annotateFragmentReferenceTransform.js.map +1 -1
  8. package/lib/compilerTransforms/annotateFragmentReferenceTransform.mjs +6 -24
  9. package/lib/compilerTransforms/annotateFragmentReferenceTransform.mjs.map +1 -1
  10. package/lib/compilerTransforms/emitApolloClientConnectionTransform.js +3 -19
  11. package/lib/compilerTransforms/emitApolloClientConnectionTransform.js.map +1 -1
  12. package/lib/compilerTransforms/emitApolloClientConnectionTransform.mjs +3 -21
  13. package/lib/compilerTransforms/emitApolloClientConnectionTransform.mjs.map +1 -1
  14. package/lib/compilerTransforms/enableNodeWatchQueryTransform.js +3 -19
  15. package/lib/compilerTransforms/enableNodeWatchQueryTransform.js.map +1 -1
  16. package/lib/compilerTransforms/enableNodeWatchQueryTransform.mjs +3 -22
  17. package/lib/compilerTransforms/enableNodeWatchQueryTransform.mjs.map +1 -1
  18. package/lib/compilerTransforms/retainConnectionDirectiveTransform.js +3 -19
  19. package/lib/compilerTransforms/retainConnectionDirectiveTransform.js.map +1 -1
  20. package/lib/compilerTransforms/retainConnectionDirectiveTransform.mjs +3 -22
  21. package/lib/compilerTransforms/retainConnectionDirectiveTransform.mjs.map +1 -1
  22. package/lib/formatModule.js +55 -77
  23. package/lib/formatModule.js.map +1 -1
  24. package/lib/formatModule.mjs +55 -78
  25. package/lib/formatModule.mjs.map +1 -1
  26. package/lib/formatModuleTransforms/extractMetadataTransform.js +3 -15
  27. package/lib/formatModuleTransforms/extractMetadataTransform.js.map +1 -1
  28. package/lib/formatModuleTransforms/extractMetadataTransform.mjs +3 -18
  29. package/lib/formatModuleTransforms/extractMetadataTransform.mjs.map +1 -1
  30. package/lib/relayCompilerLanguagePlugin.js +15 -53
  31. package/lib/relayCompilerLanguagePlugin.js.map +1 -1
  32. package/lib/relayCompilerLanguagePlugin.mjs +15 -56
  33. package/lib/relayCompilerLanguagePlugin.mjs.map +1 -1
  34. package/lib/rewriteGraphitationDirectives.js +3 -19
  35. package/lib/rewriteGraphitationDirectives.js.map +1 -1
  36. package/lib/rewriteGraphitationDirectives.mjs +3 -22
  37. package/lib/rewriteGraphitationDirectives.mjs.map +1 -1
  38. package/lib/typescriptTransforms/TypeScriptGenerator.js +27 -34
  39. package/lib/typescriptTransforms/TypeScriptGenerator.js.map +1 -1
  40. package/lib/typescriptTransforms/TypeScriptGenerator.mjs +27 -37
  41. package/lib/typescriptTransforms/TypeScriptGenerator.mjs.map +1 -1
  42. package/package.json +4 -4
@@ -1,25 +1,8 @@
1
1
  "use strict";
2
2
  var __defProp = Object.defineProperty;
3
- var __defProps = Object.defineProperties;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
10
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
11
- var __spreadValues = (a, b) => {
12
- for (var prop in b || (b = {}))
13
- if (__hasOwnProp.call(b, prop))
14
- __defNormalProp(a, prop, b[prop]);
15
- if (__getOwnPropSymbols)
16
- for (var prop of __getOwnPropSymbols(b)) {
17
- if (__propIsEnum.call(b, prop))
18
- __defNormalProp(a, prop, b[prop]);
19
- }
20
- return a;
21
- };
22
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
23
6
  var __export = (target, all) => {
24
7
  for (var name in all)
25
8
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -85,13 +68,15 @@ function visitNodeWithSelections(context, node) {
85
68
  if (selection.kind === "FragmentSpread") {
86
69
  const fragment = context.getFragment(selection.name);
87
70
  if ((0, import_utils.implementsNodeInterface)(context, fragment)) {
88
- return __spreadProps(__spreadValues({}, node), {
71
+ return {
72
+ ...node,
89
73
  selections: [...node.selections, FRAGMENTS_ON_NODE_SELECTION]
90
- });
74
+ };
91
75
  } else if (fragment.type === context.getSchema().getQueryType()) {
92
- return __spreadProps(__spreadValues({}, node), {
76
+ return {
77
+ ...node,
93
78
  selections: [...node.selections, FRAGMENTS_SELECTION]
94
- });
79
+ };
95
80
  }
96
81
  }
97
82
  }
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/compilerTransforms/annotateFragmentReferenceTransform.ts"],
4
4
  "sourcesContent": ["import {\n CompilerContext,\n Fragment,\n InlineFragment,\n LinkedField,\n Root,\n ScalarField,\n} from \"relay-compiler\";\nimport { IRTransform } from \"relay-compiler/lib/core/CompilerContext\";\nimport { visit } from \"relay-compiler/lib/core/IRVisitor\";\nimport { implementsNodeInterface } from \"./utils\";\n\nconst FRAGMENTS_SELECTION: ScalarField = {\n kind: \"ScalarField\",\n name: \"__fragments\",\n alias: \"__fragments\",\n type: \"String!\",\n directives: [\n {\n kind: \"Directive\",\n name: \"client\",\n args: [],\n loc: { kind: \"Generated\" },\n metadata: undefined,\n },\n ],\n args: [],\n loc: { kind: \"Generated\" },\n metadata: undefined,\n};\n\nconst FRAGMENTS_ON_NODE_SELECTION: InlineFragment = {\n kind: \"InlineFragment\",\n typeCondition: \"Node\",\n selections: [FRAGMENTS_SELECTION],\n directives: [],\n loc: { kind: \"Generated\" },\n metadata: undefined,\n};\n\n/**\n * Inserts a `__fragments` selection at the place where a fragment reference\n * boundary exists. This is either done in a `Node` inline fragment or directly\n * on the `Query` type.\n *\n * This field, which is an Apollo Client client-side field as declared with the\n * `@client` directive, will be used to pass context between the `use*Fragment`\n * hooks. (Currently this is limited to request variables.) The data for this\n * field is resolved by the `fragmentReferencesFieldPolicy` function.\n */\nexport const annotateFragmentReferenceTransform: IRTransform = (context) => {\n const visitor = visitNodeWithSelections.bind(null, context);\n let nextContext = context;\n\n context.forEachDocument((document) => {\n const nextDocument = visit(document, {\n Root: visitor,\n Fragment: visitor,\n InlineFragment: visitor,\n LinkedField: visitor,\n });\n nextContext = nextContext.replace(nextDocument);\n });\n\n return nextContext;\n};\n\nfunction visitNodeWithSelections(\n context: CompilerContext,\n node: Root | Fragment | InlineFragment | LinkedField\n): Root | Fragment | InlineFragment | LinkedField | undefined {\n for (const selection of node.selections) {\n if (selection.kind === \"FragmentSpread\") {\n const fragment = context.getFragment(selection.name);\n if (implementsNodeInterface(context, fragment)) {\n return {\n ...node,\n selections: [...node.selections, FRAGMENTS_ON_NODE_SELECTION],\n };\n } else if (fragment.type === context.getSchema().getQueryType()) {\n return {\n ...node,\n selections: [...node.selections, FRAGMENTS_SELECTION],\n };\n }\n }\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,uBAAsB;AACtB,mBAAwC;AAExC,MAAM,sBAAmC;AAAA,EACvC,MAAM;AAAA,EACN,MAAM;AAAA,EACN,OAAO;AAAA,EACP,MAAM;AAAA,EACN,YAAY;AAAA,IACV;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AAAA,MACN,MAAM,CAAC;AAAA,MACP,KAAK,EAAE,MAAM,YAAY;AAAA,MACzB,UAAU;AAAA,IACZ;AAAA,EACF;AAAA,EACA,MAAM,CAAC;AAAA,EACP,KAAK,EAAE,MAAM,YAAY;AAAA,EACzB,UAAU;AACZ;AAEA,MAAM,8BAA8C;AAAA,EAClD,MAAM;AAAA,EACN,eAAe;AAAA,EACf,YAAY,CAAC,mBAAmB;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EAAE,MAAM,YAAY;AAAA,EACzB,UAAU;AACZ;AAEA,MAAM,8BAA8C;AAAA,EAClD,MAAM;AAAA,EACN,eAAe;AAAA,EACf,YAAY,CAAC,mBAAmB;AAAA,EAChC,YAAY,CAAC;AAAA,EACb,KAAK,EAAE,MAAM,YAAY;AAAA,EACzB,UAAU;AACZ;AAYO,MAAM,qCAAkD,CAAC,YAAY;AAC1E,QAAM,UAAU,wBAAwB,KAAK,MAAM,OAAO;AAC1D,MAAI,cAAc;AAElB,UAAQ,gBAAgB,CAAC,aAAa;AACpC,UAAM,mBAAe,wBAAM,UAAU;AAAA,MACnC,MAAM;AAAA,MACN,UAAU;AAAA,MACV,gBAAgB;AAAA,MAChB,aAAa;AAAA,IACf,CAAC;AACD,kBAAc,YAAY,QAAQ,YAAY;AAAA,EAChD,CAAC;AAED,SAAO;AACT;AAEA,SAAS,wBACP,SACA,MAC4D;AAC5D,aAAW,aAAa,KAAK,YAAY;AACvC,QAAI,UAAU,SAAS,kBAAkB;AACvC,YAAM,WAAW,QAAQ,YAAY,UAAU,IAAI;AACnD,cAAI,sCAAwB,SAAS,QAAQ,GAAG;AAC9C,eAAO;AAAA,UACL,GAAG;AAAA,UACH,YAAY,CAAC,GAAG,KAAK,YAAY,2BAA2B;AAAA,QAC9D;AAAA,MACF,WAAW,SAAS,SAAS,QAAQ,UAAU,EAAE,aAAa,GAAG;AAC/D,eAAO;AAAA,UACL,GAAG;AAAA,UACH,YAAY,CAAC,GAAG,KAAK,YAAY,mBAAmB;AAAA,QACtD;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;",
6
6
  "names": []
7
7
  }
@@ -1,23 +1,3 @@
1
- var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- }
17
- return a;
18
- };
19
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
-
21
1
  // src/compilerTransforms/annotateFragmentReferenceTransform.ts
22
2
  import { visit } from "relay-compiler/lib/core/IRVisitor";
23
3
  import { implementsNodeInterface } from "./utils.mjs";
@@ -66,13 +46,15 @@ function visitNodeWithSelections(context, node) {
66
46
  if (selection.kind === "FragmentSpread") {
67
47
  const fragment = context.getFragment(selection.name);
68
48
  if (implementsNodeInterface(context, fragment)) {
69
- return __spreadProps(__spreadValues({}, node), {
49
+ return {
50
+ ...node,
70
51
  selections: [...node.selections, FRAGMENTS_ON_NODE_SELECTION]
71
- });
52
+ };
72
53
  } else if (fragment.type === context.getSchema().getQueryType()) {
73
- return __spreadProps(__spreadValues({}, node), {
54
+ return {
55
+ ...node,
74
56
  selections: [...node.selections, FRAGMENTS_SELECTION]
75
- });
57
+ };
76
58
  }
77
59
  }
78
60
  }
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/compilerTransforms/annotateFragmentReferenceTransform.ts"],
4
4
  "sourcesContent": ["import {\n CompilerContext,\n Fragment,\n InlineFragment,\n LinkedField,\n Root,\n ScalarField,\n} from \"relay-compiler\";\nimport { IRTransform } from \"relay-compiler/lib/core/CompilerContext\";\nimport { visit } from \"relay-compiler/lib/core/IRVisitor\";\nimport { implementsNodeInterface } from \"./utils\";\n\nconst FRAGMENTS_SELECTION: ScalarField = {\n kind: \"ScalarField\",\n name: \"__fragments\",\n alias: \"__fragments\",\n type: \"String!\",\n directives: [\n {\n kind: \"Directive\",\n name: \"client\",\n args: [],\n loc: { kind: \"Generated\" },\n metadata: undefined,\n },\n ],\n args: [],\n loc: { kind: \"Generated\" },\n metadata: undefined,\n};\n\nconst FRAGMENTS_ON_NODE_SELECTION: InlineFragment = {\n kind: \"InlineFragment\",\n typeCondition: \"Node\",\n selections: [FRAGMENTS_SELECTION],\n directives: [],\n loc: { kind: \"Generated\" },\n metadata: undefined,\n};\n\n/**\n * Inserts a `__fragments` selection at the place where a fragment reference\n * boundary exists. This is either done in a `Node` inline fragment or directly\n * on the `Query` type.\n *\n * This field, which is an Apollo Client client-side field as declared with the\n * `@client` directive, will be used to pass context between the `use*Fragment`\n * hooks. (Currently this is limited to request variables.) The data for this\n * field is resolved by the `fragmentReferencesFieldPolicy` function.\n */\nexport const annotateFragmentReferenceTransform: IRTransform = (context) => {\n const visitor = visitNodeWithSelections.bind(null, context);\n let nextContext = context;\n\n context.forEachDocument((document) => {\n const nextDocument = visit(document, {\n Root: visitor,\n Fragment: visitor,\n InlineFragment: visitor,\n LinkedField: visitor,\n });\n nextContext = nextContext.replace(nextDocument);\n });\n\n return nextContext;\n};\n\nfunction visitNodeWithSelections(\n context: CompilerContext,\n node: Root | Fragment | InlineFragment | LinkedField\n): Root | Fragment | InlineFragment | LinkedField | undefined {\n for (const selection of node.selections) {\n if (selection.kind === \"FragmentSpread\") {\n const fragment = context.getFragment(selection.name);\n if (implementsNodeInterface(context, fragment)) {\n return {\n ...node,\n selections: [...node.selections, FRAGMENTS_ON_NODE_SELECTION],\n };\n } else if (fragment.type === context.getSchema().getQueryType()) {\n return {\n ...node,\n selections: [...node.selections, FRAGMENTS_SELECTION],\n };\n }\n }\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;AASA,SAAS,aAAa;AACtB,SAAS,+BAA+B;AAExC,IAAM,sBAAmC;AAAA,EACvC,MAAM;AAAA,EACN,MAAM;AAAA,EACN,OAAO;AAAA,EACP,MAAM;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;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;",
6
6
  "names": []
7
7
  }
@@ -1,25 +1,8 @@
1
1
  "use strict";
2
2
  var __defProp = Object.defineProperty;
3
- var __defProps = Object.defineProperties;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
10
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
11
- var __spreadValues = (a, b) => {
12
- for (var prop in b || (b = {}))
13
- if (__hasOwnProp.call(b, prop))
14
- __defNormalProp(a, prop, b[prop]);
15
- if (__getOwnPropSymbols)
16
- for (var prop of __getOwnPropSymbols(b)) {
17
- if (__propIsEnum.call(b, prop))
18
- __defNormalProp(a, prop, b[prop]);
19
- }
20
- return a;
21
- };
22
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
23
6
  var __export = (target, all) => {
24
7
  for (var name in all)
25
8
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -89,7 +72,8 @@ function emitApolloClientConnectionTransform(wrappedConnectionTransform) {
89
72
  metadata: void 0
90
73
  });
91
74
  }
92
- const nextLinkedFieldNode = __spreadProps(__spreadValues({}, linkedFieldNode), {
75
+ const nextLinkedFieldNode = {
76
+ ...linkedFieldNode,
93
77
  handles: (_b = linkedFieldNode.handles) == null ? void 0 : _b.filter(
94
78
  (handle) => handle.name !== "connection"
95
79
  ),
@@ -103,7 +87,7 @@ function emitApolloClientConnectionTransform(wrappedConnectionTransform) {
103
87
  metadata: void 0
104
88
  }
105
89
  ]
106
- });
90
+ };
107
91
  return nextLinkedFieldNode;
108
92
  }
109
93
  }
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/compilerTransforms/emitApolloClientConnectionTransform.ts"],
4
4
  "sourcesContent": ["import invariant from \"invariant\";\nimport { Argument, ArgumentValue, LinkedField } from \"relay-compiler\";\nimport { IRTransform } from \"relay-compiler/lib/core/CompilerContext\";\nimport { visit } from \"relay-compiler/lib/core/IRVisitor\";\n\n// TODO: Add typings for this\nconst SchemaUtils = require(\"relay-compiler/lib/core/SchemaUtils\");\n\n/**\n * Finds connection client-handles that relay-compiler emits and replaces\n * them with a version of the `@connection` directive that Apollo Client uses;\n * which is identical to relay's version, except the `filters` parameter is\n * named `filter` (singular).\n *\n * @param wrappedConnectionTransform\n * relay-compiler's connection client-handle transform\n */\nexport function emitApolloClientConnectionTransform(\n wrappedConnectionTransform: IRTransform,\n): IRTransform {\n const connectionTransformWrapper: IRTransform = (context) => {\n const schema = context.getSchema();\n let nextContext = wrappedConnectionTransform(context);\n\n // Replaces the field handle created by the wrapped connection transform\n // with the @connection directive that Apollo Client expects\n nextContext.forEachDocument((document) => {\n const nextDocument = visit(document, {\n LinkedField(linkedFieldNode) {\n const connectionHandle = linkedFieldNode.handles?.find(\n (handle) => handle.name === \"connection\",\n );\n if (connectionHandle) {\n const args: Argument[] = [\n {\n kind: \"Argument\",\n name: \"key\",\n type: SchemaUtils.getNonNullStringInput(schema),\n value: {\n kind: \"Literal\",\n value: connectionHandle.key,\n loc: { kind: \"Generated\" },\n },\n loc: { kind: \"Generated\" },\n metadata: undefined,\n },\n ];\n if (connectionHandle.filters) {\n args.push({\n kind: \"Argument\",\n name: \"filter\",\n type: schema.assertInputType(\n schema.expectTypeFromString(\"[String!]\"),\n ),\n value: {\n kind: \"ListValue\",\n items: connectionHandle.filters.map<ArgumentValue>(\n (filter) => ({\n kind: \"Literal\",\n value: filter,\n loc: { kind: \"Generated\" },\n }),\n ),\n loc: { kind: \"Generated\" },\n metadata: undefined,\n },\n loc: { kind: \"Generated\" },\n metadata: undefined,\n });\n }\n const nextLinkedFieldNode: LinkedField = {\n ...linkedFieldNode,\n handles: linkedFieldNode.handles?.filter(\n (handle) => handle.name !== \"connection\",\n ),\n directives: [\n ...linkedFieldNode.directives,\n {\n kind: \"Directive\",\n name: \"connection\",\n args,\n loc: { kind: \"Generated\" },\n metadata: undefined,\n },\n ],\n };\n return nextLinkedFieldNode;\n }\n },\n });\n nextContext = nextContext.replace(nextDocument);\n });\n\n return nextContext;\n };\n return connectionTransformWrapper;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,uBAAsB;AAGtB,MAAM,cAAc,QAAQ,qCAAqC;AAW1D,SAAS,oCACd,4BACa;AACb,QAAM,6BAA0C,CAAC,YAAY;AAC3D,UAAM,SAAS,QAAQ,UAAU;AACjC,QAAI,cAAc,2BAA2B,OAAO;AAIpD,gBAAY,gBAAgB,CAAC,aAAa;AACxC,YAAM,mBAAe,wBAAM,UAAU;AAAA,QACnC,YAAY,iBAAiB;AA5BrC;AA6BU,gBAAM,oBAAmB,qBAAgB,YAAhB,mBAAyB;AAAA,YAChD,CAAC,WAAW,OAAO,SAAS;AAAA;AAE9B,cAAI,kBAAkB;AACpB,kBAAM,OAAmB;AAAA,cACvB;AAAA,gBACE,MAAM;AAAA,gBACN,MAAM;AAAA,gBACN,MAAM,YAAY,sBAAsB,MAAM;AAAA,gBAC9C,OAAO;AAAA,kBACL,MAAM;AAAA,kBACN,OAAO,iBAAiB;AAAA,kBACxB,KAAK,EAAE,MAAM,YAAY;AAAA,gBAC3B;AAAA,gBACA,KAAK,EAAE,MAAM,YAAY;AAAA,gBACzB,UAAU;AAAA,cACZ;AAAA,YACF;AACA,gBAAI,iBAAiB,SAAS;AAC5B,mBAAK,KAAK;AAAA,gBACR,MAAM;AAAA,gBACN,MAAM;AAAA,gBACN,MAAM,OAAO;AAAA,kBACX,OAAO,qBAAqB,WAAW;AAAA,gBACzC;AAAA,gBACA,OAAO;AAAA,kBACL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EACT;AACA,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -1,22 +1,3 @@
1
- var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- }
17
- return a;
18
- };
19
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
1
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
21
2
  get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
22
3
  }) : x)(function(x) {
@@ -77,7 +58,8 @@ function emitApolloClientConnectionTransform(wrappedConnectionTransform) {
77
58
  metadata: void 0
78
59
  });
79
60
  }
80
- const nextLinkedFieldNode = __spreadProps(__spreadValues({}, linkedFieldNode), {
61
+ const nextLinkedFieldNode = {
62
+ ...linkedFieldNode,
81
63
  handles: (_b = linkedFieldNode.handles) == null ? void 0 : _b.filter(
82
64
  (handle) => handle.name !== "connection"
83
65
  ),
@@ -91,7 +73,7 @@ function emitApolloClientConnectionTransform(wrappedConnectionTransform) {
91
73
  metadata: void 0
92
74
  }
93
75
  ]
94
- });
76
+ };
95
77
  return nextLinkedFieldNode;
96
78
  }
97
79
  }
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/compilerTransforms/emitApolloClientConnectionTransform.ts"],
4
4
  "sourcesContent": ["import invariant from \"invariant\";\nimport { Argument, ArgumentValue, LinkedField } from \"relay-compiler\";\nimport { IRTransform } from \"relay-compiler/lib/core/CompilerContext\";\nimport { visit } from \"relay-compiler/lib/core/IRVisitor\";\n\n// TODO: Add typings for this\nconst SchemaUtils = require(\"relay-compiler/lib/core/SchemaUtils\");\n\n/**\n * Finds connection client-handles that relay-compiler emits and replaces\n * them with a version of the `@connection` directive that Apollo Client uses;\n * which is identical to relay's version, except the `filters` parameter is\n * named `filter` (singular).\n *\n * @param wrappedConnectionTransform\n * relay-compiler's connection client-handle transform\n */\nexport function emitApolloClientConnectionTransform(\n wrappedConnectionTransform: IRTransform,\n): IRTransform {\n const connectionTransformWrapper: IRTransform = (context) => {\n const schema = context.getSchema();\n let nextContext = wrappedConnectionTransform(context);\n\n // Replaces the field handle created by the wrapped connection transform\n // with the @connection directive that Apollo Client expects\n nextContext.forEachDocument((document) => {\n const nextDocument = visit(document, {\n LinkedField(linkedFieldNode) {\n const connectionHandle = linkedFieldNode.handles?.find(\n (handle) => handle.name === \"connection\",\n );\n if (connectionHandle) {\n const args: Argument[] = [\n {\n kind: \"Argument\",\n name: \"key\",\n type: SchemaUtils.getNonNullStringInput(schema),\n value: {\n kind: \"Literal\",\n value: connectionHandle.key,\n loc: { kind: \"Generated\" },\n },\n loc: { kind: \"Generated\" },\n metadata: undefined,\n },\n ];\n if (connectionHandle.filters) {\n args.push({\n kind: \"Argument\",\n name: \"filter\",\n type: schema.assertInputType(\n schema.expectTypeFromString(\"[String!]\"),\n ),\n value: {\n kind: \"ListValue\",\n items: connectionHandle.filters.map<ArgumentValue>(\n (filter) => ({\n kind: \"Literal\",\n value: filter,\n loc: { kind: \"Generated\" },\n }),\n ),\n loc: { kind: \"Generated\" },\n metadata: undefined,\n },\n loc: { kind: \"Generated\" },\n metadata: undefined,\n });\n }\n const nextLinkedFieldNode: LinkedField = {\n ...linkedFieldNode,\n handles: linkedFieldNode.handles?.filter(\n (handle) => handle.name !== \"connection\",\n ),\n directives: [\n ...linkedFieldNode.directives,\n {\n kind: \"Directive\",\n name: \"connection\",\n args,\n loc: { kind: \"Generated\" },\n metadata: undefined,\n },\n ],\n };\n return nextLinkedFieldNode;\n }\n },\n });\n nextContext = nextContext.replace(nextDocument);\n });\n\n return nextContext;\n };\n return connectionTransformWrapper;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,SAAS,aAAa;AAGtB,IAAM,cAAc,UAAQ,qCAAqC;AAW1D,SAAS,oCACd,4BACa;AACb,QAAM,6BAA0C,CAAC,YAAY;AAC3D,UAAM,SAAS,QAAQ,UAAU;AACjC,QAAI,cAAc,2BAA2B,OAAO;AAIpD,gBAAY,gBAAgB,CAAC,aAAa;AACxC,YAAM,eAAe,MAAM,UAAU;AAAA,QACnC,YAAY,iBAAiB;AA5BrC;AA6BU,gBAAM,oBAAmB,qBAAgB,YAAhB,mBAAyB;AAAA,YAChD,CAAC,WAAW,OAAO,SAAS;AAAA;AAE9B,cAAI,kBAAkB;AACpB,kBAAM,OAAmB;AAAA,cACvB;AAAA,gBACE,MAAM;AAAA,gBACN,MAAM;AAAA,gBACN,MAAM,YAAY,sBAAsB,MAAM;AAAA,gBAC9C,OAAO;AAAA,kBACL,MAAM;AAAA,kBACN,OAAO,iBAAiB;AAAA,kBACxB,KAAK,EAAE,MAAM,YAAY;AAAA,gBAC3B;AAAA,gBACA,KAAK,EAAE,MAAM,YAAY;AAAA,gBACzB,UAAU;AAAA,cACZ;AAAA,YACF;AACA,gBAAI,iBAAiB,SAAS;AAC5B,mBAAK,KAAK;AAAA,gBACR,MAAM;AAAA,gBACN,MAAM;AAAA,gBACN,MAAM,OAAO;AAAA,kBACX,OAAO,qBAAqB,WAAW;AAAA,gBACzC;AAAA,gBACA,OAAO;AAAA,kBACL,MAAM;AAAA,kBACN,OAAO,iBAAiB,QAAQ;AAAA,oBAC9B,CAAC,YAAY;AAAA,sBACX,MA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AAA,kBACL,MAAM;AAAA,kBACN,OAAO,iBAAiB;AAAA,kBACxB,KAAK,EAAE,MAAM,YAAY;AAAA,gBAC3B;AAAA,gBACA,KAAK,EAAE,MAAM,YAAY;AAAA,gBACzB,UAAU;AAAA,cACZ;AAAA,YACF;AACA,gBAAI,iBAAiB,SAAS;AAC5B,mBAAK,KAAK;AAAA,gBACR,MAAM;AAAA,gBACN,MAAM;AAAA,gBACN,MAAM,OAAO;AAAA,kBACX,OAAO,qBAAqB,WAAW;AAAA,gBACzC;AAAA,gBACA,OAAO;AAAA,kBACL,MAAM;AAAA,kBACN,OAAO,iBAAiB,QAAQ;AAAA,oBAC9B,CAAC,YAAY;AAAA,sBACX,MAAM;AAAA,sBACN,OAAO;AAAA,sBACP,KAAK,EAAE,MAAM,YAAY;AAAA,oBAC3B;AAAA,kBACF;AAAA,kBACA,KAAK,EAAE,MAAM,YAAY;AAAA,kBACzB,UAAU;AAAA,gBACZ;AAAA,gBACA,KAAK,EAAE,MAAM,YAAY;AAAA,gBACzB,UAAU;AAAA,cACZ,CAAC;AAAA,YACH;AACA,kBAAM,sBAAmC;AAAA,cACvC,GAAG;AAAA,cACH,UAAS,qBAAgB,YAAhB,mBAAyB;AAAA,gBAChC,CAAC,WAAW,OAAO,SAAS;AAAA;AAAA,cAE9B,YAAY;AAAA,gBACV,GAAG,gBAAgB;AAAA,gBACnB;AAAA,kBACE,MAAM;AAAA,kBACN,MAAM;AAAA,kBACN;AAAA,kBACA,KAAK,EAAE,MAAM,YAAY;AAAA,kBACzB,UAAU;AAAA,gBACZ;AAAA,cACF;AAAA,YACF;AACA,mBAAO;AAAA,UACT;AAAA,QACF;AAAA,MACF,CAAC;AACD,oBAAc,YAAY,QAAQ,YAAY;AAAA,IAChD,CAAC;AAED,WAAO;AAAA,EACT;AACA,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -1,25 +1,8 @@
1
1
  "use strict";
2
2
  var __defProp = Object.defineProperty;
3
- var __defProps = Object.defineProperties;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
10
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
11
- var __spreadValues = (a, b) => {
12
- for (var prop in b || (b = {}))
13
- if (__hasOwnProp.call(b, prop))
14
- __defNormalProp(a, prop, b[prop]);
15
- if (__getOwnPropSymbols)
16
- for (var prop of __getOwnPropSymbols(b)) {
17
- if (__propIsEnum.call(b, prop))
18
- __defNormalProp(a, prop, b[prop]);
19
- }
20
- return a;
21
- };
22
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
23
6
  var __export = (target, all) => {
24
7
  for (var name in all)
25
8
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -43,12 +26,13 @@ const enableNodeWatchQueryTransform = (context) => {
43
26
  let nextContext = context;
44
27
  context.forEachDocument((document) => {
45
28
  if (document.kind === "Fragment" && (document.type === context.getSchema().getQueryType() || (0, import_utils.implementsNodeInterface)(context, document))) {
46
- nextContext = nextContext.replace(__spreadProps(__spreadValues({}, document), {
29
+ nextContext = nextContext.replace({
30
+ ...document,
47
31
  directives: [
48
32
  ...document.directives,
49
33
  emitRefetchableDirective(document)
50
34
  ]
51
- }));
35
+ });
52
36
  }
53
37
  });
54
38
  return nextContext;
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/compilerTransforms/enableNodeWatchQueryTransform.ts"],
4
4
  "sourcesContent": ["import { Directive, Fragment } from \"relay-compiler\";\nimport { IRTransform } from \"relay-compiler/lib/core/CompilerContext\";\nimport { implementsNodeInterface } from \"./utils\";\n\n/**\n * Uses relay-compiler's `@refetchable` directive to emit a query operation for\n * a single fragment (on the `Node` interface or `Query` type). This operation\n * is used by the `use*Fragment` hooks to observe the Apollo Client store for\n * changes to _just_ that data selected in the fragment.\n */\nexport const enableNodeWatchQueryTransform: IRTransform = (context) => {\n let nextContext = context;\n\n context.forEachDocument((document) => {\n if (\n document.kind === \"Fragment\" &&\n (document.type === context.getSchema().getQueryType() ||\n implementsNodeInterface(context, document))\n ) {\n nextContext = nextContext.replace({\n ...document,\n directives: [\n ...document.directives,\n emitRefetchableDirective(document),\n ],\n });\n }\n });\n\n return nextContext;\n};\n\nfunction emitRefetchableDirective(fragmentDefinition: Fragment): Directive {\n const fragmentName = fragmentDefinition.name;\n const fragmentBaseName = fragmentName.replace(/Fragment$/, \"\");\n return {\n kind: \"Directive\",\n name: \"refetchable\",\n args: [\n {\n kind: \"Argument\",\n name: \"queryName\",\n value: {\n kind: \"Literal\",\n value: `${fragmentBaseName}WatchNodeQuery`,\n loc: { kind: \"Generated\" },\n },\n loc: { kind: \"Generated\" },\n metadata: undefined,\n },\n ],\n loc: { kind: \"Generated\" },\n metadata: undefined,\n };\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAAwC;AAQjC,MAAM,gCAA6C,CAAC,YAAY;AACrE,MAAI,cAAc;AAElB,UAAQ,gBAAgB,CAAC,aAAa;AACpC,QACE,SAAS,SAAS,eACjB,SAAS,SAAS,QAAQ,UAAU,EAAE,aAAa,SAClD,sCAAwB,SAAS,QAAQ,IAC3C;AACA,oBAAc,YAAY,QAAQ,iCAC7B,WAD6B;AAAA,QAEhC,YAAY;AAAA,UACV,GAAG,SAAS;AAAA,UACZ,yBAAyB,QAAQ;AAAA,QACnC;AAAA,MACF,EAAC;AAAA,IACH;AAAA,EACF,CAAC;AAED,SAAO;AACT;AAEA,SAAS,yBAAyB,oBAAyC;AACzE,QAAM,eAAe,mBAAmB;AACxC,QAAM,mBAAmB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,IACA,KAAK,EAAE,MAAM,YAAY;AAAA,IACzB,UAAU;AAAA,EACZ;AACF;",
6
6
  "names": []
7
7
  }
@@ -1,35 +1,16 @@
1
- var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- }
17
- return a;
18
- };
19
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
-
21
1
  // src/compilerTransforms/enableNodeWatchQueryTransform.ts
22
2
  import { implementsNodeInterface } from "./utils.mjs";
23
3
  var enableNodeWatchQueryTransform = (context) => {
24
4
  let nextContext = context;
25
5
  context.forEachDocument((document) => {
26
6
  if (document.kind === "Fragment" && (document.type === context.getSchema().getQueryType() || implementsNodeInterface(context, document))) {
27
- nextContext = nextContext.replace(__spreadProps(__spreadValues({}, document), {
7
+ nextContext = nextContext.replace({
8
+ ...document,
28
9
  directives: [
29
10
  ...document.directives,
30
11
  emitRefetchableDirective(document)
31
12
  ]
32
- }));
13
+ });
33
14
  }
34
15
  });
35
16
  return nextContext;
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/compilerTransforms/enableNodeWatchQueryTransform.ts"],
4
4
  "sourcesContent": ["import { Directive, Fragment } from \"relay-compiler\";\nimport { IRTransform } from \"relay-compiler/lib/core/CompilerContext\";\nimport { implementsNodeInterface } from \"./utils\";\n\n/**\n * Uses relay-compiler's `@refetchable` directive to emit a query operation for\n * a single fragment (on the `Node` interface or `Query` type). This operation\n * is used by the `use*Fragment` hooks to observe the Apollo Client store for\n * changes to _just_ that data selected in the fragment.\n */\nexport const enableNodeWatchQueryTransform: IRTransform = (context) => {\n let nextContext = context;\n\n context.forEachDocument((document) => {\n if (\n document.kind === \"Fragment\" &&\n (document.type === context.getSchema().getQueryType() ||\n implementsNodeInterface(context, document))\n ) {\n nextContext = nextContext.replace({\n ...document,\n directives: [\n ...document.directives,\n emitRefetchableDirective(document),\n ],\n });\n }\n });\n\n return nextContext;\n};\n\nfunction emitRefetchableDirective(fragmentDefinition: Fragment): Directive {\n const fragmentName = fragmentDefinition.name;\n const fragmentBaseName = fragmentName.replace(/Fragment$/, \"\");\n return {\n kind: \"Directive\",\n name: \"refetchable\",\n args: [\n {\n kind: \"Argument\",\n name: \"queryName\",\n value: {\n kind: \"Literal\",\n value: `${fragmentBaseName}WatchNodeQuery`,\n loc: { kind: \"Generated\" },\n },\n loc: { kind: \"Generated\" },\n metadata: undefined,\n },\n ],\n loc: { kind: \"Generated\" },\n metadata: undefined,\n };\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;AAEA,SAAS,+BAA+B;AAQjC,IAAM,gCAA6C,CAAC,YAAY;AACrE,MAAI,cAAc;AAElB,UAAQ,gBAAgB,CAAC,aAAa;AACpC,QACE,SAAS,SAAS,eACjB,SAAS,SAAS,QAAQ,UAAU,EAAE,aAAa,KAClD,wBAAwB,SAAS,QAAQ,IAC3C;AACA,oBAAc,YAAY,QAAQ,iCAC7B,WAD6B;AAAA,QAEhC,YAAY;AAAA,UACV,GAAG,SAAS;AAAA,UACZ,yBAAyB,QAAQ;AAAA,QACnC;AAAA,MACF,EAAC;AAAA,IACH;AAAA,EACF,CAAC;AAED,SAAO;AACT;AAEA,SAAS,yBAAyB,oBAAyC;AACzE,QAAM,eAAe,mBAAmB;AACxC,Q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AA,IACzB,UAAU;AAAA,EACZ;AACF;",
6
6
  "names": []
7
7
  }
@@ -1,25 +1,8 @@
1
1
  "use strict";
2
2
  var __defProp = Object.defineProperty;
3
- var __defProps = Object.defineProperties;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
10
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
11
- var __spreadValues = (a, b) => {
12
- for (var prop in b || (b = {}))
13
- if (__hasOwnProp.call(b, prop))
14
- __defNormalProp(a, prop, b[prop]);
15
- if (__getOwnPropSymbols)
16
- for (var prop of __getOwnPropSymbols(b)) {
17
- if (__propIsEnum.call(b, prop))
18
- __defNormalProp(a, prop, b[prop]);
19
- }
20
- return a;
21
- };
22
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
23
6
  var __export = (target, all) => {
24
7
  for (var name in all)
25
8
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -67,9 +50,10 @@ function retainConnectionDirectiveTransform(wrappedFilterDirectivesTransform) {
67
50
  ([p, _]) => path.length === p.length && path.every((x, i) => p[i] === x)
68
51
  );
69
52
  if (match) {
70
- const nextLinkedFieldNode = __spreadProps(__spreadValues({}, linkedFieldNode), {
53
+ const nextLinkedFieldNode = {
54
+ ...linkedFieldNode,
71
55
  directives: [...linkedFieldNode.directives, match[1]]
72
- });
56
+ };
73
57
  return nextLinkedFieldNode;
74
58
  }
75
59
  }
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/compilerTransforms/retainConnectionDirectiveTransform.ts"],
4
4
  "sourcesContent": ["import { IRTransform } from \"relay-compiler/lib/core/CompilerContext\";\nimport { Directive, LinkedField } from \"relay-compiler/lib/core/IR\";\nimport { visit } from \"relay-compiler/lib/core/IRVisitor\";\n\ntype PathWithConnectionDirective = [any[], Directive];\n\n/**\n * relay-compiler will strip out all of its client-specific directives, which\n * makes sense as these should normally not be sent to the schema, but in our\n * case we want to keep this directive as we will need to send it to Apollo\n * Client. So we collect all the directives, let the relay-compiler filter\n * transform do its work, and then re-instate the connection directives.\n *\n * @param wrappedFilterDirectivesTransform\n * relay-compiler's filter directives transform\n */\nexport function retainConnectionDirectiveTransform(\n wrappedFilterDirectivesTransform: IRTransform,\n): IRTransform {\n const filterDirectivesTransformWrapper: IRTransform = (context) => {\n let nextContext = context;\n const documentsWithConnectionDirectives: Record<\n string,\n PathWithConnectionDirective[]\n > = {};\n\n // Store @connection directives\n nextContext.forEachDocument((document) => {\n const fieldPathsWithConnectionDirectives: PathWithConnectionDirective[] =\n [];\n visit(document, {\n Directive(directiveNode, _key, _parent, path) {\n if (directiveNode.name === \"connection\") {\n fieldPathsWithConnectionDirectives.push([\n path!.slice(0, -2),\n directiveNode,\n ]);\n }\n },\n });\n documentsWithConnectionDirectives[document.name] =\n fieldPathsWithConnectionDirectives;\n });\n\n // Apply original upstream transform\n nextContext = wrappedFilterDirectivesTransform(context);\n\n // Re-add @connection directives\n nextContext.forEachDocument((document) => {\n const fieldPathsWithConnectionDirectives =\n documentsWithConnectionDirectives[document.name];\n if (fieldPathsWithConnectionDirectives.length > 0) {\n const nextDocument = visit(document, {\n LinkedField(linkedFieldNode, _key, _parent, path) {\n const match = fieldPathsWithConnectionDirectives.find(\n ([p, _]) =>\n path!.length === p.length && path!.every((x, i) => p[i] === x),\n );\n if (match) {\n const nextLinkedFieldNode: LinkedField = {\n ...linkedFieldNode,\n directives: [...linkedFieldNode.directives, match[1]],\n };\n return nextLinkedFieldNode;\n }\n },\n });\n nextContext = nextContext.replace(nextDocument);\n }\n });\n\n return nextContext;\n };\n return filterDirectivesTransformWrapper;\n}\n"],
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AAAA;AAEA,uBAAsB;AAcf,SAAS,mCACd,kCACa;AACb,QAAM,mCAAgD,CAAC,YAAY;AACjE,QAAI,cAAc;AAClB,UAAM,oCAGF,CAAC;AAGL,gBAAY,gBAAgB,CAAC,aAAa;AACxC,YAAM,qCACJ,CAAC;AACH,kCAAM,UAAU;AAAA,QACd,UAAU,eAAe,MAAM,SAAS,MAAM;AAC5C,cAAI,cAAc,SAAS,cAAc;AACvC,+CAAmC,KAAK;AAAA,cACtC,KAAM,MAAM,GAAG,EAAE;AAAA,cACjB;AAAA,YACF,CAAC;AAAA,UACH;AAAA,QACF;AAAA,MACF,CAAC;AACD,wCAAkC,SAAS,IAAI,IAC7C;AAAA,IACJ,CAAC;AAGD,kBAAc,iCAAiC,OAAO;AAGtD,gBAAY,gBAAgB,CAAC,aAAa;AACxC,YAAM,qCACJ,kCAAkC,SAAS,IAAI;AACjD,UAAI,mCAAmC,SAAS,GAAG;AACjD,cAAM,mBAAe,wBAAM,UAAU;AAAA,UACnC,YAAY,iBAAiB,MAAM,SAAS,MAAM;AAChD,kBAAM,QAAQ,mCAAmC;AAAA,cAC/C,CAAC,CAAC,GAAG,CAAC,MACJ,KAAM,WAAW,EAAE,UAAU,KAAM,MAAM,CAAC,GAAG,MAAM,EAAE,CAAC,MAAM,CAAC;AAAA,YACjE;AACA,gBAAI,OAAO;AACT,oBAAM,sBAAmC;AAAA,gBACvC,GAAG;AAAA,gBACH,YAAY,CAAC,GAAG,gBAAgB,YAAY,MAAM,CAAC,CAAC;AAAA,cACtD;AACA,qBAAO;AAAA,YACT;AAAA,UACF;AAAA,QACF,CAAC;AACD,sBAAc,YAAY,QAAQ,YAAY;AAAA,MAChD;AAAA,IACF,CAAC;AAED,WAAO;AAAA,EACT;AACA,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -1,23 +1,3 @@
1
- var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- }
17
- return a;
18
- };
19
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
-
21
1
  // src/compilerTransforms/retainConnectionDirectiveTransform.ts
22
2
  import { visit } from "relay-compiler/lib/core/IRVisitor";
23
3
  function retainConnectionDirectiveTransform(wrappedFilterDirectivesTransform) {
@@ -48,9 +28,10 @@ function retainConnectionDirectiveTransform(wrappedFilterDirectivesTransform) {
48
28
  ([p, _]) => path.length === p.length && path.every((x, i) => p[i] === x)
49
29
  );
50
30
  if (match) {
51
- const nextLinkedFieldNode = __spreadProps(__spreadValues({}, linkedFieldNode), {
31
+ const nextLinkedFieldNode = {
32
+ ...linkedFieldNode,
52
33
  directives: [...linkedFieldNode.directives, match[1]]
53
- });
34
+ };
54
35
  return nextLinkedFieldNode;
55
36
  }
56
37
  }
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/compilerTransforms/retainConnectionDirectiveTransform.ts"],
4
4
  "sourcesContent": ["import { IRTransform } from \"relay-compiler/lib/core/CompilerContext\";\nimport { Directive, LinkedField } from \"relay-compiler/lib/core/IR\";\nimport { visit } from \"relay-compiler/lib/core/IRVisitor\";\n\ntype PathWithConnectionDirective = [any[], Directive];\n\n/**\n * relay-compiler will strip out all of its client-specific directives, which\n * makes sense as these should normally not be sent to the schema, but in our\n * case we want to keep this directive as we will need to send it to Apollo\n * Client. So we collect all the directives, let the relay-compiler filter\n * transform do its work, and then re-instate the connection directives.\n *\n * @param wrappedFilterDirectivesTransform\n * relay-compiler's filter directives transform\n */\nexport function retainConnectionDirectiveTransform(\n wrappedFilterDirectivesTransform: IRTransform,\n): IRTransform {\n const filterDirectivesTransformWrapper: IRTransform = (context) => {\n let nextContext = context;\n const documentsWithConnectionDirectives: Record<\n string,\n PathWithConnectionDirective[]\n > = {};\n\n // Store @connection directives\n nextContext.forEachDocument((document) => {\n const fieldPathsWithConnectionDirectives: PathWithConnectionDirective[] =\n [];\n visit(document, {\n Directive(directiveNode, _key, _parent, path) {\n if (directiveNode.name === \"connection\") {\n fieldPathsWithConnectionDirectives.push([\n path!.slice(0, -2),\n directiveNode,\n ]);\n }\n },\n });\n documentsWithConnectionDirectives[document.name] =\n fieldPathsWithConnectionDirectives;\n });\n\n // Apply original upstream transform\n nextContext = wrappedFilterDirectivesTransform(context);\n\n // Re-add @connection directives\n nextContext.forEachDocument((document) => {\n const fieldPathsWithConnectionDirectives =\n documentsWithConnectionDirectives[document.name];\n if (fieldPathsWithConnectionDirectives.length > 0) {\n const nextDocument = visit(document, {\n LinkedField(linkedFieldNode, _key, _parent, path) {\n const match = fieldPathsWithConnectionDirectives.find(\n ([p, _]) =>\n path!.length === p.length && path!.every((x, i) => p[i] === x),\n );\n if (match) {\n const nextLinkedFieldNode: LinkedField = {\n ...linkedFieldNode,\n directives: [...linkedFieldNode.directives, match[1]],\n };\n return nextLinkedFieldNode;\n }\n },\n });\n nextContext = nextContext.replace(nextDocument);\n }\n });\n\n return nextContext;\n };\n return filterDirectivesTransformWrapper;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;AAEA,SAAS,aAAa;AAcf,SAAS,mCACd,kCACa;AACb,QAAM,mCAAgD,CAAC,YAAY;AACjE,QAAI,cAAc;AAClB,UAAM,oCAGF,CAAC;AAGL,gBAAY,gBAAgB,CAAC,aAAa;AACxC,YAAM,qCACJ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