@apollo/gateway 2.4.4 → 2.4.5

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 (117) hide show
  1. package/dist/__generated__/graphqlTypes.d.ts +160 -0
  2. package/dist/__generated__/graphqlTypes.d.ts.map +1 -0
  3. package/dist/__generated__/graphqlTypes.js +30 -0
  4. package/dist/__generated__/graphqlTypes.js.map +1 -0
  5. package/dist/config.d.ts +138 -0
  6. package/dist/config.d.ts.map +1 -0
  7. package/dist/config.js +60 -0
  8. package/dist/config.js.map +1 -0
  9. package/dist/dataRewrites.d.ts +5 -0
  10. package/dist/dataRewrites.d.ts.map +1 -0
  11. package/dist/dataRewrites.js +103 -0
  12. package/dist/dataRewrites.js.map +1 -0
  13. package/dist/datasources/LocalGraphQLDataSource.d.ts +10 -0
  14. package/dist/datasources/LocalGraphQLDataSource.d.ts.map +1 -0
  15. package/dist/datasources/LocalGraphQLDataSource.js +31 -0
  16. package/dist/datasources/LocalGraphQLDataSource.js.map +1 -0
  17. package/dist/datasources/RemoteGraphQLDataSource.d.ts +24 -0
  18. package/dist/datasources/RemoteGraphQLDataSource.d.ts.map +1 -0
  19. package/dist/datasources/RemoteGraphQLDataSource.js +180 -0
  20. package/dist/datasources/RemoteGraphQLDataSource.js.map +1 -0
  21. package/dist/datasources/index.d.ts +4 -0
  22. package/dist/datasources/index.d.ts.map +1 -0
  23. package/dist/datasources/index.js +8 -0
  24. package/dist/datasources/index.js.map +1 -0
  25. package/dist/datasources/parseCacheControlHeader.d.ts +2 -0
  26. package/dist/datasources/parseCacheControlHeader.d.ts.map +1 -0
  27. package/dist/datasources/parseCacheControlHeader.js +16 -0
  28. package/dist/datasources/parseCacheControlHeader.js.map +1 -0
  29. package/dist/datasources/types.d.ts +23 -0
  30. package/dist/datasources/types.d.ts.map +1 -0
  31. package/dist/datasources/types.js +10 -0
  32. package/dist/datasources/types.js.map +1 -0
  33. package/dist/executeQueryPlan.d.ts +15 -0
  34. package/dist/executeQueryPlan.d.ts.map +1 -0
  35. package/dist/executeQueryPlan.js +539 -0
  36. package/dist/executeQueryPlan.js.map +1 -0
  37. package/dist/index.d.ts +113 -0
  38. package/dist/index.d.ts.map +1 -0
  39. package/dist/index.js +590 -0
  40. package/dist/index.js.map +1 -0
  41. package/dist/logger.d.ts +3 -0
  42. package/dist/logger.d.ts.map +1 -0
  43. package/dist/logger.js +15 -0
  44. package/dist/logger.js.map +1 -0
  45. package/dist/operationContext.d.ts +17 -0
  46. package/dist/operationContext.d.ts.map +1 -0
  47. package/dist/operationContext.js +38 -0
  48. package/dist/operationContext.js.map +1 -0
  49. package/dist/resultShaping.d.ts +12 -0
  50. package/dist/resultShaping.d.ts.map +1 -0
  51. package/dist/resultShaping.js +229 -0
  52. package/dist/resultShaping.js.map +1 -0
  53. package/dist/schema-helper/addExtensions.d.ts +3 -0
  54. package/dist/schema-helper/addExtensions.d.ts.map +1 -0
  55. package/dist/schema-helper/addExtensions.js +23 -0
  56. package/dist/schema-helper/addExtensions.js.map +1 -0
  57. package/dist/supergraphManagers/IntrospectAndCompose/index.d.ts +31 -0
  58. package/dist/supergraphManagers/IntrospectAndCompose/index.d.ts.map +1 -0
  59. package/dist/supergraphManagers/IntrospectAndCompose/index.js +112 -0
  60. package/dist/supergraphManagers/IntrospectAndCompose/index.js.map +1 -0
  61. package/dist/supergraphManagers/IntrospectAndCompose/loadServicesFromRemoteEndpoint.d.ts +12 -0
  62. package/dist/supergraphManagers/IntrospectAndCompose/loadServicesFromRemoteEndpoint.d.ts.map +1 -0
  63. package/dist/supergraphManagers/IntrospectAndCompose/loadServicesFromRemoteEndpoint.js +57 -0
  64. package/dist/supergraphManagers/IntrospectAndCompose/loadServicesFromRemoteEndpoint.js.map +1 -0
  65. package/dist/supergraphManagers/LegacyFetcher/index.d.ts +33 -0
  66. package/dist/supergraphManagers/LegacyFetcher/index.d.ts.map +1 -0
  67. package/dist/supergraphManagers/LegacyFetcher/index.js +149 -0
  68. package/dist/supergraphManagers/LegacyFetcher/index.js.map +1 -0
  69. package/dist/supergraphManagers/LocalCompose/index.d.ts +19 -0
  70. package/dist/supergraphManagers/LocalCompose/index.d.ts.map +1 -0
  71. package/dist/supergraphManagers/LocalCompose/index.js +55 -0
  72. package/dist/supergraphManagers/LocalCompose/index.js.map +1 -0
  73. package/dist/supergraphManagers/UplinkSupergraphManager/index.d.ts +63 -0
  74. package/dist/supergraphManagers/UplinkSupergraphManager/index.d.ts.map +1 -0
  75. package/dist/supergraphManagers/UplinkSupergraphManager/index.js +210 -0
  76. package/dist/supergraphManagers/UplinkSupergraphManager/index.js.map +1 -0
  77. package/dist/supergraphManagers/UplinkSupergraphManager/loadSupergraphSdlFromStorage.d.ts +30 -0
  78. package/dist/supergraphManagers/UplinkSupergraphManager/loadSupergraphSdlFromStorage.d.ts.map +1 -0
  79. package/dist/supergraphManagers/UplinkSupergraphManager/loadSupergraphSdlFromStorage.js +145 -0
  80. package/dist/supergraphManagers/UplinkSupergraphManager/loadSupergraphSdlFromStorage.js.map +1 -0
  81. package/dist/supergraphManagers/UplinkSupergraphManager/outOfBandReporter.d.ts +14 -0
  82. package/dist/supergraphManagers/UplinkSupergraphManager/outOfBandReporter.d.ts.map +1 -0
  83. package/dist/supergraphManagers/UplinkSupergraphManager/outOfBandReporter.js +85 -0
  84. package/dist/supergraphManagers/UplinkSupergraphManager/outOfBandReporter.js.map +1 -0
  85. package/dist/supergraphManagers/index.d.ts +6 -0
  86. package/dist/supergraphManagers/index.d.ts.map +1 -0
  87. package/dist/supergraphManagers/index.js +27 -0
  88. package/dist/supergraphManagers/index.js.map +1 -0
  89. package/dist/typings/graphql.d.ts +11 -0
  90. package/dist/typings/graphql.d.ts.map +1 -0
  91. package/dist/typings/graphql.js +3 -0
  92. package/dist/typings/graphql.js.map +1 -0
  93. package/dist/utilities/array.d.ts +5 -0
  94. package/dist/utilities/array.d.ts.map +1 -0
  95. package/dist/utilities/array.js +46 -0
  96. package/dist/utilities/array.js.map +1 -0
  97. package/dist/utilities/assert.d.ts +2 -0
  98. package/dist/utilities/assert.d.ts.map +1 -0
  99. package/dist/utilities/assert.js +10 -0
  100. package/dist/utilities/assert.js.map +1 -0
  101. package/dist/utilities/deepMerge.d.ts +2 -0
  102. package/dist/utilities/deepMerge.d.ts.map +1 -0
  103. package/dist/utilities/deepMerge.js +34 -0
  104. package/dist/utilities/deepMerge.js.map +1 -0
  105. package/dist/utilities/graphql.d.ts +5 -0
  106. package/dist/utilities/graphql.d.ts.map +1 -0
  107. package/dist/utilities/graphql.js +28 -0
  108. package/dist/utilities/graphql.js.map +1 -0
  109. package/dist/utilities/opentelemetry.d.ts +10 -0
  110. package/dist/utilities/opentelemetry.d.ts.map +1 -0
  111. package/dist/utilities/opentelemetry.js +19 -0
  112. package/dist/utilities/opentelemetry.js.map +1 -0
  113. package/dist/utilities/predicates.d.ts +2 -0
  114. package/dist/utilities/predicates.d.ts.map +1 -0
  115. package/dist/utilities/predicates.js +11 -0
  116. package/dist/utilities/predicates.js.map +1 -0
  117. package/package.json +4 -4
@@ -0,0 +1,17 @@
1
+ import { DocumentNode, FragmentDefinitionNode, GraphQLSchema, OperationDefinitionNode } from 'graphql';
2
+ type FragmentMap = {
3
+ [fragmentName: string]: FragmentDefinitionNode;
4
+ };
5
+ export type OperationContext = {
6
+ schema: GraphQLSchema;
7
+ operation: OperationDefinitionNode;
8
+ fragments: FragmentMap;
9
+ };
10
+ interface BuildOperationContextOptions {
11
+ schema: GraphQLSchema;
12
+ operationDocument: DocumentNode;
13
+ operationName?: string;
14
+ }
15
+ export declare function buildOperationContext({ schema, operationDocument, operationName, }: BuildOperationContextOptions): OperationContext;
16
+ export {};
17
+ //# sourceMappingURL=operationContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operationContext.d.ts","sourceRoot":"","sources":["../src/operationContext.ts"],"names":[],"mappings":"AACA,OAAO,EACL,YAAY,EACZ,sBAAsB,EACtB,aAAa,EAEb,uBAAuB,EACxB,MAAM,SAAS,CAAC;AAEjB,KAAK,WAAW,GAAG;IAAE,CAAC,YAAY,EAAE,MAAM,GAAG,sBAAsB,CAAA;CAAE,CAAC;AAEtE,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,EAAE,aAAa,CAAC;IACtB,SAAS,EAAE,uBAAuB,CAAC;IACnC,SAAS,EAAE,WAAW,CAAC;CACxB,CAAC;AAGF,UAAU,4BAA4B;IACpC,MAAM,EAAE,aAAa,CAAC;IACtB,iBAAiB,EAAE,YAAY,CAAC;IAChC,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,wBAAgB,qBAAqB,CAAC,EACpC,MAAM,EACN,iBAAiB,EACjB,aAAa,GACd,EAAE,4BAA4B,GAAG,gBAAgB,CAuCjD"}
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildOperationContext = void 0;
4
+ const federation_internals_1 = require("@apollo/federation-internals");
5
+ const graphql_1 = require("graphql");
6
+ function buildOperationContext({ schema, operationDocument, operationName, }) {
7
+ let operation;
8
+ let operationCount = 0;
9
+ const fragments = Object.create(null);
10
+ operationDocument.definitions.forEach(definition => {
11
+ switch (definition.kind) {
12
+ case graphql_1.Kind.OPERATION_DEFINITION:
13
+ operationCount++;
14
+ if (!operationName && operationCount > 1) {
15
+ throw federation_internals_1.ERRORS.INVALID_GRAPHQL.err('Must provide operation name if query contains ' +
16
+ 'multiple operations.');
17
+ }
18
+ if (!operationName ||
19
+ (definition.name && definition.name.value === operationName)) {
20
+ operation = definition;
21
+ }
22
+ break;
23
+ case graphql_1.Kind.FRAGMENT_DEFINITION:
24
+ fragments[definition.name.value] = definition;
25
+ break;
26
+ }
27
+ });
28
+ if (!operation) {
29
+ throw federation_internals_1.ERRORS.INVALID_GRAPHQL.err(operationName ? `Unknown operation named "${operationName}".` : 'Must provide an operation.');
30
+ }
31
+ return {
32
+ schema,
33
+ operation,
34
+ fragments,
35
+ };
36
+ }
37
+ exports.buildOperationContext = buildOperationContext;
38
+ //# sourceMappingURL=operationContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operationContext.js","sourceRoot":"","sources":["../src/operationContext.ts"],"names":[],"mappings":";;;AAAA,uEAAsD;AACtD,qCAMiB;AAiBjB,SAAgB,qBAAqB,CAAC,EACpC,MAAM,EACN,iBAAiB,EACjB,aAAa,GACgB;IAC7B,IAAI,SAA8C,CAAC;IACnD,IAAI,cAAc,GAAG,CAAC,CAAC;IACvB,MAAM,SAAS,GAEX,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACxB,iBAAiB,CAAC,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;QACjD,QAAQ,UAAU,CAAC,IAAI,EAAE;YACvB,KAAK,cAAI,CAAC,oBAAoB;gBAC5B,cAAc,EAAE,CAAC;gBACjB,IAAI,CAAC,aAAa,IAAI,cAAc,GAAG,CAAC,EAAE;oBACxC,MAAM,6BAAM,CAAC,eAAe,CAAC,GAAG,CAC9B,gDAAgD;wBAC9C,sBAAsB,CACzB,CAAC;iBACH;gBACD,IACE,CAAC,aAAa;oBACd,CAAC,UAAU,CAAC,IAAI,IAAI,UAAU,CAAC,IAAI,CAAC,KAAK,KAAK,aAAa,CAAC,EAC5D;oBACA,SAAS,GAAG,UAAU,CAAC;iBACxB;gBACD,MAAM;YACR,KAAK,cAAI,CAAC,mBAAmB;gBAC3B,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,UAAU,CAAC;gBAC9C,MAAM;SACT;IACH,CAAC,CAAC,CAAC;IACH,IAAI,CAAC,SAAS,EAAE;QACd,MAAM,6BAAM,CAAC,eAAe,CAAC,GAAG,CAC9B,aAAa,CAAC,CAAC,CAAC,4BAA4B,aAAa,IAAI,CAAC,CAAC,CAAC,4BAA4B,CAC7F,CAAC;KACH;IAED,OAAO;QACL,MAAM;QACN,SAAS;QACT,SAAS;KACV,CAAC;AACJ,CAAC;AA3CD,sDA2CC"}
@@ -0,0 +1,12 @@
1
+ import { FieldSelection, Operation } from "@apollo/federation-internals";
2
+ import { GraphQLError } from "graphql";
3
+ export declare function computeResponse({ operation, variables, input, introspectionHandling, }: {
4
+ operation: Operation;
5
+ variables?: Record<string, any>;
6
+ input: Record<string, any> | null | undefined;
7
+ introspectionHandling: (introspectionSelection: FieldSelection) => any;
8
+ }): {
9
+ data: Record<string, any> | null | undefined;
10
+ errors: GraphQLError[];
11
+ };
12
+ //# sourceMappingURL=resultShaping.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resultShaping.d.ts","sourceRoot":"","sources":["../src/resultShaping.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,cAAc,EAOd,SAAS,EAQV,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AA8BvC,wBAAgB,eAAe,CAAC,EAC9B,SAAS,EACT,SAAS,EACT,KAAK,EACL,qBAAqB,GACtB,EAAE;IACD,SAAS,EAAE,SAAS,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAChC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC;IAC9C,qBAAqB,EAAE,CAAC,sBAAsB,EAAE,cAAc,KAAK,GAAG,CAAC;CACxE,GAAG;IACF,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC;IAC7C,MAAM,EAAE,YAAY,EAAE,CAAC;CACxB,CA+BA"}
@@ -0,0 +1,229 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.computeResponse = void 0;
4
+ const federation_internals_1 = require("@apollo/federation-internals");
5
+ function computeResponse({ operation, variables, input, introspectionHandling, }) {
6
+ if (!input) {
7
+ return { data: input, errors: [] };
8
+ }
9
+ const parameters = {
10
+ schema: operation.schema,
11
+ variables: {
12
+ ...operation.collectDefaultedVariableValues(),
13
+ ...variables,
14
+ },
15
+ errors: [],
16
+ introspectionHandling,
17
+ };
18
+ const data = Object.create(null);
19
+ const res = applySelectionSet({
20
+ input,
21
+ selectionSet: operation.selectionSet,
22
+ output: data,
23
+ parameters,
24
+ path: [],
25
+ parentType: operation.schema.schemaDefinition.rootType(operation.rootKind),
26
+ });
27
+ return {
28
+ data: res === ApplyResult.NULL_BUBBLE_UP ? null : data,
29
+ errors: parameters.errors,
30
+ };
31
+ }
32
+ exports.computeResponse = computeResponse;
33
+ function shouldSkip(element, parameters) {
34
+ const skipDirective = element.appliedDirectivesOf(parameters.schema.skipDirective())[0];
35
+ const includeDirective = element.appliedDirectivesOf(parameters.schema.includeDirective())[0];
36
+ return (skipDirective && ifValue(skipDirective, parameters.variables))
37
+ || (includeDirective && !ifValue(includeDirective, parameters.variables));
38
+ }
39
+ function ifValue(directive, variables) {
40
+ const ifArg = directive.arguments().if;
41
+ if (ifArg instanceof federation_internals_1.Variable) {
42
+ const value = variables[ifArg.name];
43
+ (0, federation_internals_1.assert)(value !== undefined && typeof value === 'boolean', () => `Unexpected value ${value} for variable ${ifArg} of ${directive}`);
44
+ return value;
45
+ }
46
+ else {
47
+ return ifArg;
48
+ }
49
+ }
50
+ var ApplyResult;
51
+ (function (ApplyResult) {
52
+ ApplyResult[ApplyResult["OK"] = 0] = "OK";
53
+ ApplyResult[ApplyResult["NULL_BUBBLE_UP"] = 1] = "NULL_BUBBLE_UP";
54
+ })(ApplyResult || (ApplyResult = {}));
55
+ function typeConditionApplies(schema, typeCondition, typename, parentType) {
56
+ if (!typeCondition) {
57
+ return true;
58
+ }
59
+ if (typename) {
60
+ const type = schema.type(typename);
61
+ return !!type && (0, federation_internals_1.isSubtype)(typeCondition, type);
62
+ }
63
+ else {
64
+ return (0, federation_internals_1.isSubtype)(typeCondition, parentType);
65
+ }
66
+ }
67
+ function applySelectionSet({ input, selectionSet, output, parameters, path, parentType, }) {
68
+ var _a, _b, _c, _d;
69
+ for (const selection of selectionSet.selections()) {
70
+ if (shouldSkip(selection.element, parameters)) {
71
+ continue;
72
+ }
73
+ if (selection.kind === 'FieldSelection') {
74
+ const field = selection.element;
75
+ const fieldType = field.definition.type;
76
+ const responseName = field.responseName();
77
+ const outputValue = output[responseName];
78
+ if (field.definition.isSchemaIntrospectionField()) {
79
+ if (outputValue === undefined) {
80
+ output[responseName] = parameters.introspectionHandling(selection);
81
+ }
82
+ continue;
83
+ }
84
+ let inputValue = (_a = input[responseName]) !== null && _a !== void 0 ? _a : null;
85
+ if (field.name === federation_internals_1.typenameFieldName) {
86
+ if (outputValue === undefined) {
87
+ if (inputValue === null && responseName !== federation_internals_1.typenameFieldName) {
88
+ inputValue = (_b = input[federation_internals_1.typenameFieldName]) !== null && _b !== void 0 ? _b : null;
89
+ }
90
+ const type = inputValue !== null && typeof inputValue === 'string'
91
+ ? (_c = parameters.schema.type(inputValue)) !== null && _c !== void 0 ? _c : parentType
92
+ : parentType;
93
+ if (!(0, federation_internals_1.isObjectType)(type)) {
94
+ return ApplyResult.NULL_BUBBLE_UP;
95
+ }
96
+ output[responseName] = type.name;
97
+ }
98
+ continue;
99
+ }
100
+ path.push(responseName);
101
+ const { updated, isInvalid } = updateOutputValue({
102
+ outputValue,
103
+ type: fieldType,
104
+ inputValue,
105
+ selectionSet: selection.selectionSet,
106
+ path,
107
+ parameters,
108
+ parentType,
109
+ });
110
+ output[responseName] = updated;
111
+ path.pop();
112
+ if (isInvalid) {
113
+ return ApplyResult.NULL_BUBBLE_UP;
114
+ }
115
+ }
116
+ else {
117
+ const fragment = selection.element;
118
+ const typename = input[federation_internals_1.typenameFieldName];
119
+ (0, federation_internals_1.assert)(!typename || typeof typename === 'string', () => `Got unexpected value for __typename: ${typename}`);
120
+ if (typeConditionApplies(parameters.schema, fragment.typeCondition, typename, parentType)) {
121
+ const res = applySelectionSet({
122
+ input,
123
+ selectionSet: selection.selectionSet,
124
+ output,
125
+ parameters,
126
+ path,
127
+ parentType: (_d = fragment.typeCondition) !== null && _d !== void 0 ? _d : parentType,
128
+ });
129
+ if (res === ApplyResult.NULL_BUBBLE_UP) {
130
+ return ApplyResult.NULL_BUBBLE_UP;
131
+ }
132
+ }
133
+ }
134
+ }
135
+ return ApplyResult.OK;
136
+ }
137
+ function pathLastElementDescription(path, currentType, parentType) {
138
+ const element = path[path.length - 1];
139
+ (0, federation_internals_1.assert)(element !== undefined, 'Should not have been called on an empty path');
140
+ return typeof element === 'string'
141
+ ? `field ${parentType}.${element}`
142
+ : `array element of type ${currentType} at index ${element}`;
143
+ }
144
+ function updateOutputValue({ outputValue, type, inputValue, selectionSet, path, parameters, parentType, }) {
145
+ (0, federation_internals_1.assert)(inputValue !== undefined, 'Should not pass undefined for `inputValue` to this method');
146
+ if (outputValue === null || (outputValue !== undefined && !selectionSet)) {
147
+ return { updated: outputValue };
148
+ }
149
+ if ((0, federation_internals_1.isNonNullType)(type)) {
150
+ const { updated, hasErrors } = updateOutputValue({
151
+ outputValue,
152
+ type: type.ofType,
153
+ inputValue,
154
+ selectionSet,
155
+ path,
156
+ parameters,
157
+ parentType,
158
+ });
159
+ if (updated === null) {
160
+ if (!hasErrors) {
161
+ parameters.errors.push(federation_internals_1.ERRORS.INVALID_GRAPHQL.err(`Cannot return null for non-nullable ${pathLastElementDescription(path, type.ofType, parentType)}.`, { path: Array.from(path) }));
162
+ }
163
+ return { updated, isInvalid: true, hasErrors: true };
164
+ }
165
+ return { updated };
166
+ }
167
+ if (inputValue === null) {
168
+ return { updated: null };
169
+ }
170
+ if ((0, federation_internals_1.isListType)(type)) {
171
+ (0, federation_internals_1.assert)(Array.isArray(inputValue), () => `Invalid non-list value ${inputValue} returned by subgraph for list type ${type}`);
172
+ (0, federation_internals_1.assert)(outputValue === undefined || Array.isArray(outputValue), () => `Invalid non-list value ${outputValue} returned by subgraph for list type ${type}`);
173
+ const outputValueList = outputValue === undefined ? new Array(inputValue.length).fill(undefined) : outputValue;
174
+ (0, federation_internals_1.assert)(inputValue.length === outputValueList.length, () => `[${inputValue}].length (${inputValue.length}) !== [${outputValueList}].length (${outputValueList.length})`);
175
+ let shouldNullify = false;
176
+ let hasErrors = false;
177
+ const updated = outputValueList.map((outputEltValue, idx) => {
178
+ path.push(idx);
179
+ const elt = updateOutputValue({
180
+ outputValue: outputEltValue,
181
+ type: type.ofType,
182
+ inputValue: inputValue[idx],
183
+ selectionSet,
184
+ path,
185
+ parameters,
186
+ parentType,
187
+ });
188
+ path.pop();
189
+ shouldNullify || (shouldNullify = !!elt.isInvalid);
190
+ hasErrors || (hasErrors = !!elt.hasErrors);
191
+ return elt.updated;
192
+ });
193
+ return { updated: shouldNullify ? null : updated, hasErrors };
194
+ }
195
+ if ((0, federation_internals_1.isCompositeType)(type)) {
196
+ (0, federation_internals_1.assert)(selectionSet, () => `Invalid empty selection set for composite type ${type}`);
197
+ (0, federation_internals_1.assert)(typeof inputValue === 'object', () => `Invalid non-object value ${inputValue} returned by subgraph for composite type ${type}`);
198
+ (0, federation_internals_1.assert)(outputValue === undefined || typeof outputValue === 'object', () => `Invalid non-object value ${inputValue} returned by subgraph for composite type ${type}`);
199
+ const inputTypename = inputValue[federation_internals_1.typenameFieldName];
200
+ (0, federation_internals_1.assert)(inputTypename === undefined || typeof inputTypename === 'string', () => `Invalid non-string value ${inputTypename} for __typename at ${path}`);
201
+ let objType = type;
202
+ if (inputTypename) {
203
+ const typenameType = parameters.schema.type(inputTypename);
204
+ if (!typenameType || !(0, federation_internals_1.isCompositeType)(typenameType)) {
205
+ parameters.errors.push(federation_internals_1.ERRORS.INVALID_GRAPHQL.err(`Invalid __typename found for object at ${pathLastElementDescription(path, type, parentType)}.`, { path: Array.from(path) }));
206
+ return { updated: null, hasErrors: true };
207
+ }
208
+ objType = typenameType;
209
+ }
210
+ const outputValueObject = outputValue === undefined ? Object.create(null) : outputValue;
211
+ const res = applySelectionSet({
212
+ input: inputValue,
213
+ selectionSet,
214
+ output: outputValueObject,
215
+ parameters,
216
+ path,
217
+ parentType: objType,
218
+ });
219
+ const hasErrors = res === ApplyResult.NULL_BUBBLE_UP;
220
+ return { updated: hasErrors ? null : outputValueObject, hasErrors };
221
+ }
222
+ (0, federation_internals_1.assert)(outputValue === undefined, () => `Excepted output to be undefined but got ${type} for type ${type}`);
223
+ const isValidValue = (0, federation_internals_1.isValidLeafValue)(parameters.schema, inputValue, type);
224
+ if (!isValidValue) {
225
+ parameters.errors.push(federation_internals_1.ERRORS.INVALID_GRAPHQL.err(`Invalid value found for ${pathLastElementDescription(path, type, parentType)}.`, { path: Array.from(path) }));
226
+ }
227
+ return { updated: isValidValue ? inputValue : null, hasErrors: !isValidValue };
228
+ }
229
+ //# sourceMappingURL=resultShaping.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resultShaping.js","sourceRoot":"","sources":["../src/resultShaping.ts"],"names":[],"mappings":";;;AAAA,uEAoBsC;AAgCtC,SAAgB,eAAe,CAAC,EAC9B,SAAS,EACT,SAAS,EACT,KAAK,EACL,qBAAqB,GAMtB;IAIC,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;KACpC;IAED,MAAM,UAAU,GAAG;QACjB,MAAM,EAAE,SAAS,CAAC,MAAM;QACxB,SAAS,EAAE;YACT,GAAG,SAAS,CAAC,8BAA8B,EAAE;YAE7C,GAAG,SAAS;SACb;QACD,MAAM,EAAE,EAAE;QACV,qBAAqB;KACtB,CAAC;IAEF,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAEjC,MAAM,GAAG,GAAG,iBAAiB,CAAC;QAC5B,KAAK;QACL,YAAY,EAAE,SAAS,CAAC,YAAY;QACpC,MAAM,EAAE,IAAI;QACZ,UAAU;QACV,IAAI,EAAE,EAAE;QACR,UAAU,EAAE,SAAS,CAAC,MAAM,CAAC,gBAAgB,CAAC,QAAQ,CA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,CAAC;QACrD,OAAO,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,iBAAiB,EAAE,SAAS,EAAE,CAAC;KACrE;IAKD,IAAA,6BAAM,EAAC,WAAW,KAAK,SAAS,EAAE,GAAG,EAAE,CAAC,2CAA2C,IAAI,aAAa,IAAI,EAAE,CAAC,CAAA;IAE3G,MAAM,YAAY,GAAG,IAAA,uCAAgB,EAAC,UAAU,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;IAC3E,IAAI,CAAC,YAAY,EAAE;QACjB,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,6BAAM,CAAC,eAAe,CAAC,GAAG,CAC/C,2BAA2B,0BAA0B,CAAC,IAAI,EAAE,IAAI,EAAE,UAAU,CAAC,GAAG,EAChF,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAC3B,CAAC,CAAC;KACJ;IAGD,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC,YAAY,EAAC,CAAC;AAChF,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { GraphQLSchema } from 'graphql';
2
+ export declare function addExtensions(schema: GraphQLSchema): GraphQLSchema;
3
+ //# sourceMappingURL=addExtensions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addExtensions.d.ts","sourceRoot":"","sources":["../../src/schema-helper/addExtensions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAKxC,wBAAgB,aAAa,CAAC,MAAM,EAAE,aAAa,GAAG,aAAa,CAiBlE"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addExtensions = void 0;
4
+ const { version } = require('../../package.json');
5
+ function addExtensions(schema) {
6
+ var _a, _b, _c;
7
+ const schemaExtension = (_a = schema.extensions) !== null && _a !== void 0 ? _a : {};
8
+ const apolloExtension = (_b = schemaExtension === null || schemaExtension === void 0 ? void 0 : schemaExtension.apollo) !== null && _b !== void 0 ? _b : {};
9
+ const gatewayExtension = (_c = apolloExtension === null || apolloExtension === void 0 ? void 0 : apolloExtension.gateway) !== null && _c !== void 0 ? _c : {};
10
+ schema.extensions = {
11
+ ...schema.extensions,
12
+ apollo: {
13
+ ...apolloExtension,
14
+ gateway: {
15
+ ...gatewayExtension,
16
+ version,
17
+ }
18
+ },
19
+ };
20
+ return schema;
21
+ }
22
+ exports.addExtensions = addExtensions;
23
+ //# sourceMappingURL=addExtensions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addExtensions.js","sourceRoot":"","sources":["../../src/schema-helper/addExtensions.ts"],"names":[],"mappings":";;;AAGA,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAElD,SAAgB,aAAa,CAAC,MAAqB;;IACjD,MAAM,eAAe,GAAkC,MAAA,MAAM,CAAC,UAAU,mCAAI,EAAE,CAAC;IAC/E,MAAM,eAAe,GAAG,MAAA,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,MAAM,mCAAI,EAAE,CAAC;IACtD,MAAM,gBAAgB,GAAG,MAAA,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,OAAO,mCAAI,EAAE,CAAC;IAExD,MAAM,CAAC,UAAU,GAAG;QAClB,GAAG,MAAM,CAAC,UAAU;QACpB,MAAM,EAAE;YACN,GAAG,eAAe;YAClB,OAAO,EAAE;gBACP,GAAG,gBAAgB;gBACnB,OAAO;aACR;SACF;KACF,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC;AAjBD,sCAiBC"}
@@ -0,0 +1,31 @@
1
+ import type { Logger } from '@apollo/utils.logger';
2
+ import type { HeadersInit } from 'node-fetch';
3
+ import { ServiceEndpointDefinition } from '../..';
4
+ import { SupergraphManager, SupergraphSdlHookOptions } from '../../config';
5
+ export interface IntrospectAndComposeOptions {
6
+ subgraphs: ServiceEndpointDefinition[];
7
+ introspectionHeaders?: HeadersInit | ((service: ServiceEndpointDefinition) => Promise<HeadersInit> | HeadersInit);
8
+ pollIntervalInMs?: number;
9
+ logger?: Logger;
10
+ subgraphHealthCheck?: boolean;
11
+ }
12
+ export declare class IntrospectAndCompose implements SupergraphManager {
13
+ private config;
14
+ private update?;
15
+ private healthCheck?;
16
+ private subgraphs?;
17
+ private serviceSdlCache;
18
+ private timerRef;
19
+ private state;
20
+ constructor(options: IntrospectAndComposeOptions);
21
+ initialize({ update, getDataSource, healthCheck }: SupergraphSdlHookOptions): Promise<{
22
+ supergraphSdl: string;
23
+ cleanup: () => Promise<void>;
24
+ }>;
25
+ private updateSupergraphSdl;
26
+ private createSupergraphFromSubgraphList;
27
+ private beginPolling;
28
+ private poll;
29
+ private logUpdateFailure;
30
+ }
31
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/supergraphManagers/IntrospectAndCompose/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,OAAO,EACL,yBAAyB,EAG1B,MAAM,OAAO,CAAC;AAKf,OAAO,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAI3E,MAAM,WAAW,2BAA2B;IAC1C,SAAS,EAAE,yBAAyB,EAAE,CAAC;IACvC,oBAAoB,CAAC,EACjB,WAAW,GACX,CAAC,CACC,OAAO,EAAE,yBAAyB,KAC/B,OAAO,CAAC,WAAW,CAAC,GAAG,WAAW,CAAC,CAAC;IAC7C,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAOD,qBAAa,oBAAqB,YAAW,iBAAiB;IAC5D,OAAO,CAAC,MAAM,CAA8B;IAC5C,OAAO,CAAC,MAAM,CAAC,CAA8B;IAC7C,OAAO,CAAC,WAAW,CAAC,CAA8B;IAClD,OAAO,CAAC,SAAS,CAAC,CAAY;IAC9B,OAAO,CAAC,eAAe,CAAkC;IACzD,OAAO,CAAC,QAAQ,CAA+B;IAC/C,OAAO,CAAC,KAAK,CAAQ;gBAET,OAAO,EAAE,2BAA2B;IAKnC,UAAU,CAAC,EAAE,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,EAAE,wBAAwB;;;;YA2C1E,mBAAmB;IAsBjC,OAAO,CAAC,gCAAgC;IAexC,OAAO,CAAC,YAAY;IAKpB,OAAO,CAAC,IAAI;IAqBZ,OAAO,CAAC,gBAAgB;CAMzB"}
@@ -0,0 +1,112 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.IntrospectAndCompose = void 0;
7
+ const resolvable_1 = __importDefault(require("@josephg/resolvable"));
8
+ const loadServicesFromRemoteEndpoint_1 = require("./loadServicesFromRemoteEndpoint");
9
+ const composition_1 = require("@apollo/composition");
10
+ class IntrospectAndCompose {
11
+ constructor(options) {
12
+ this.serviceSdlCache = new Map();
13
+ this.timerRef = null;
14
+ this.config = options;
15
+ this.state = { phase: 'initialized' };
16
+ }
17
+ async initialize({ update, getDataSource, healthCheck }) {
18
+ this.update = update;
19
+ if (this.config.subgraphHealthCheck) {
20
+ this.healthCheck = healthCheck;
21
+ }
22
+ this.subgraphs = this.config.subgraphs.map((subgraph) => ({
23
+ ...subgraph,
24
+ dataSource: getDataSource(subgraph),
25
+ }));
26
+ let initialSupergraphSdl = null;
27
+ try {
28
+ initialSupergraphSdl = await this.updateSupergraphSdl();
29
+ }
30
+ catch (e) {
31
+ this.logUpdateFailure(e);
32
+ throw e;
33
+ }
34
+ if (this.config.pollIntervalInMs) {
35
+ this.beginPolling();
36
+ }
37
+ return {
38
+ supergraphSdl: initialSupergraphSdl,
39
+ cleanup: async () => {
40
+ if (this.state.phase === 'polling') {
41
+ await this.state.pollingPromise;
42
+ }
43
+ this.state = { phase: 'stopped' };
44
+ if (this.timerRef) {
45
+ clearTimeout(this.timerRef);
46
+ this.timerRef = null;
47
+ }
48
+ },
49
+ };
50
+ }
51
+ async updateSupergraphSdl() {
52
+ var _a;
53
+ const result = await (0, loadServicesFromRemoteEndpoint_1.loadServicesFromRemoteEndpoint)({
54
+ serviceList: this.subgraphs,
55
+ getServiceIntrospectionHeaders: async (service) => {
56
+ return typeof this.config.introspectionHeaders === 'function'
57
+ ? await this.config.introspectionHeaders(service)
58
+ : this.config.introspectionHeaders;
59
+ },
60
+ serviceSdlCache: this.serviceSdlCache,
61
+ });
62
+ if (!result.isNewSchema) {
63
+ return null;
64
+ }
65
+ const supergraphSdl = this.createSupergraphFromSubgraphList(result.serviceDefinitions);
66
+ await ((_a = this.healthCheck) === null || _a === void 0 ? void 0 : _a.call(this, supergraphSdl));
67
+ return supergraphSdl;
68
+ }
69
+ createSupergraphFromSubgraphList(subgraphs) {
70
+ const compositionResult = (0, composition_1.composeServices)(subgraphs);
71
+ if (compositionResult.errors) {
72
+ const { errors } = compositionResult;
73
+ throw Error("A valid schema couldn't be composed. The following composition errors were found:\n" +
74
+ errors.map((e) => '\t' + e.message).join('\n'));
75
+ }
76
+ else {
77
+ const { supergraphSdl } = compositionResult;
78
+ return supergraphSdl;
79
+ }
80
+ }
81
+ beginPolling() {
82
+ this.state = { phase: 'polling' };
83
+ this.poll();
84
+ }
85
+ poll() {
86
+ this.timerRef = setTimeout(async () => {
87
+ var _a;
88
+ if (this.state.phase === 'polling') {
89
+ const pollingPromise = (0, resolvable_1.default)();
90
+ this.state.pollingPromise = pollingPromise;
91
+ try {
92
+ const maybeNewSupergraphSdl = await this.updateSupergraphSdl();
93
+ if (maybeNewSupergraphSdl) {
94
+ (_a = this.update) === null || _a === void 0 ? void 0 : _a.call(this, maybeNewSupergraphSdl);
95
+ }
96
+ }
97
+ catch (e) {
98
+ this.logUpdateFailure(e);
99
+ }
100
+ pollingPromise.resolve();
101
+ }
102
+ this.poll();
103
+ }, this.config.pollIntervalInMs);
104
+ }
105
+ logUpdateFailure(e) {
106
+ var _a, _b;
107
+ (_a = this.config.logger) === null || _a === void 0 ? void 0 : _a.error('IntrospectAndCompose failed to update supergraph with the following error: ' +
108
+ ((_b = e.message) !== null && _b !== void 0 ? _b : e));
109
+ }
110
+ }
111
+ exports.IntrospectAndCompose = IntrospectAndCompose;
112
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/supergraphManagers/IntrospectAndCompose/index.ts"],"names":[],"mappings":";;;;;;AAEA,qEAA6C;AAM7C,qFAG0C;AAE1C,qDAAsD;AAoBtD,MAAa,oBAAoB;IAS/B,YAAY,OAAoC;QAJxC,oBAAe,GAAwB,IAAI,GAAG,EAAE,CAAC;QACjD,aAAQ,GAA0B,IAAI,CAAC;QAI7C,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC;QACtB,IAAI,CAAC,KAAK,GAAG,EAAE,KAAK,EAAE,aAAa,EAAE,CAAC;IACxC,CAAC;IAEM,KAAK,CAAC,UAAU,CAAC,EAAE,MAAM,EAAE,aAAa,EAAE,WAAW,EAA4B;QACtF,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAErB,IAAI,IAAI,CAAC,MAAM,CAAC,mBAAmB,EAAE;YACnC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;SAChC;QAED,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;YACxD,GAAG,QAAQ;YACX,UAAU,EAAE,aAAa,C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AAC;qBACtC;iBACF;gBAAC,OAAO,CAAC,EAAE;oBACV,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC;iBAC1B;gBACD,cAAc,CAAC,OAAO,EAAE,CAAC;aAC1B;YAED,IAAI,CAAC,IAAI,EAAE,CAAC;QACd,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,gBAAiB,CAAC,CAAC;IACpC,CAAC;IAEO,gBAAgB,CAAC,CAAM;;QAC7B,MAAA,IAAI,CAAC,MAAM,CAAC,MAAM,0CAAE,KAAK,CACvB,6EAA6E;YAC3E,CAAC,MAAA,CAAC,CAAC,OAAO,mCAAI,CAAC,CAAC,CACnB,CAAC;IACJ,CAAC;CACF;AA9HD,oDA8HC"}
@@ -0,0 +1,12 @@
1
+ import { type HeadersInit } from 'node-fetch';
2
+ import { GraphQLDataSource } from '../../datasources/types';
3
+ import { ServiceDefinitionUpdate, ServiceEndpointDefinition } from '../../config';
4
+ export type Service = ServiceEndpointDefinition & {
5
+ dataSource: GraphQLDataSource;
6
+ };
7
+ export declare function loadServicesFromRemoteEndpoint({ serviceList, getServiceIntrospectionHeaders, serviceSdlCache, }: {
8
+ serviceList: Service[];
9
+ getServiceIntrospectionHeaders: (service: ServiceEndpointDefinition) => Promise<HeadersInit | undefined>;
10
+ serviceSdlCache: Map<string, string>;
11
+ }): Promise<ServiceDefinitionUpdate>;
12
+ //# sourceMappingURL=loadServicesFromRemoteEndpoint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loadServicesFromRemoteEndpoint.d.ts","sourceRoot":"","sources":["../../../src/supergraphManagers/IntrospectAndCompose/loadServicesFromRemoteEndpoint.ts"],"names":[],"mappings":"AACA,OAAO,EAAW,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AAEvD,OAAO,EAAE,iBAAiB,EAAgC,MAAM,yBAAyB,CAAC;AAE1F,OAAO,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AAGlF,MAAM,MAAM,OAAO,GAAG,yBAAyB,GAAG;IAChD,UAAU,EAAE,iBAAiB,CAAC;CAC/B,CAAC;AAEF,wBAAsB,8BAA8B,CAAC,EACnD,WAAW,EACX,8BAA8B,EAC9B,eAAe,GAChB,EAAE;IACD,WAAW,EAAE,OAAO,EAAE,CAAC;IACvB,8BAA8B,EAAE,CAC9B,OAAO,EAAE,yBAAyB,KAC/B,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC,CAAC;IACtC,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACtC,GAAG,OAAO,CAAC,uBAAuB,CAAC,CA4DnC"}
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.loadServicesFromRemoteEndpoint = void 0;
4
+ const graphql_1 = require("graphql");
5
+ const node_fetch_1 = require("node-fetch");
6
+ const types_1 = require("../../datasources/types");
7
+ const __1 = require("../..");
8
+ async function loadServicesFromRemoteEndpoint({ serviceList, getServiceIntrospectionHeaders, serviceSdlCache, }) {
9
+ if (!serviceList || !serviceList.length) {
10
+ throw new Error('Tried to load services from remote endpoints but none provided');
11
+ }
12
+ let isNewSchema = false;
13
+ const promiseOfServiceList = serviceList.map(async ({ name, url, dataSource }) => {
14
+ if (!url) {
15
+ throw new Error(`Tried to load schema for '${name}' but no 'url' was specified.`);
16
+ }
17
+ const request = {
18
+ query: __1.SERVICE_DEFINITION_QUERY,
19
+ http: {
20
+ url,
21
+ method: 'POST',
22
+ headers: new node_fetch_1.Headers(await getServiceIntrospectionHeaders({ name, url })),
23
+ },
24
+ };
25
+ return dataSource
26
+ .process({
27
+ kind: types_1.GraphQLDataSourceRequestKind.LOADING_SCHEMA,
28
+ request,
29
+ context: {},
30
+ })
31
+ .then(({ data, errors }) => {
32
+ if (data && !errors) {
33
+ const typeDefs = data._service.sdl;
34
+ const previousDefinition = serviceSdlCache.get(name);
35
+ if (previousDefinition !== typeDefs) {
36
+ isNewSchema = true;
37
+ }
38
+ serviceSdlCache.set(name, typeDefs);
39
+ return {
40
+ name,
41
+ url,
42
+ typeDefs: (0, graphql_1.parse)(typeDefs),
43
+ };
44
+ }
45
+ throw new Error(errors === null || errors === void 0 ? void 0 : errors.map((e) => e.message).join('\n'));
46
+ })
47
+ .catch((err) => {
48
+ const errorMessage = `Couldn't load service definitions for "${name}" at ${url}` +
49
+ (err && err.message ? ': ' + err.message || err : '');
50
+ throw new Error(errorMessage);
51
+ });
52
+ });
53
+ const serviceDefinitions = await Promise.all(promiseOfServiceList);
54
+ return { serviceDefinitions, isNewSchema };
55
+ }
56
+ exports.loadServicesFromRemoteEndpoint = loadServicesFromRemoteEndpoint;
57
+ //# sourceMappingURL=loadServicesFromRemoteEndpoint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loadServicesFromRemoteEndpoint.js","sourceRoot":"","sources":["../../../src/supergraphManagers/IntrospectAndCompose/loadServicesFromRemoteEndpoint.ts"],"names":[],"mappings":";;;AAAA,qCAAgC;AAChC,2CAAuD;AAEvD,mDAA0F;AAC1F,6BAAiD;AAQ1C,KAAK,UAAU,8BAA8B,CAAC,EACnD,WAAW,EACX,8BAA8B,EAC9B,eAAe,GAOhB;IACC,IAAI,CAAC,WAAW,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE;QACvC,MAAM,IAAI,KAAK,CACb,gEAAgE,CACjE,CAAC;KACH;IAED,IAAI,WAAW,GAAG,KAAK,CAAC;IAExB,MAAM,oBAAoB,GAAG,WAAW,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,UAAU,EAAE,EAAE,EAAE;QAC/E,IAAI,CAAC,GAAG,EAAE;YACR,MAAM,IAAI,KAAK,CACb,6BAA6B,IAAI,+BAA+B,CAAC,CAAC;SACrE;QAED,MAAM,OAAO,GAA0B;YACrC,KAAK,EAAE,4BAAwB;YAC/B,IAAI,EAAE;gBACJ,GAAG;gBACH,MAAM,EAAE,MAAM;gBAC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AAC,CAAC,CAAC;IAEH,MAAM,kBAAkB,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;IACnE,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,CAAA;AAC5C,CAAC;AAtED,wEAsEC"}
@@ -0,0 +1,33 @@
1
+ import type { Logger } from '@apollo/utils.logger';
2
+ import { SupergraphManager, SupergraphSdlHookOptions, DynamicGatewayConfig } from '../../config';
3
+ import { Experimental_UpdateComposition } from '../..';
4
+ export interface LegacyFetcherOptions {
5
+ pollIntervalInMs?: number;
6
+ logger?: Logger;
7
+ subgraphHealthCheck?: boolean;
8
+ updateServiceDefinitions: Experimental_UpdateComposition;
9
+ gatewayConfig: DynamicGatewayConfig;
10
+ }
11
+ export declare class LegacyFetcher implements SupergraphManager {
12
+ private config;
13
+ private update?;
14
+ private healthCheck?;
15
+ private getDataSource?;
16
+ private timerRef;
17
+ private state;
18
+ private compositionId?;
19
+ private serviceDefinitions?;
20
+ constructor(options: LegacyFetcherOptions);
21
+ private issueDeprecationWarnings;
22
+ initialize({ update, healthCheck, getDataSource, }: SupergraphSdlHookOptions): Promise<{
23
+ supergraphSdl: string;
24
+ cleanup: () => Promise<void>;
25
+ }>;
26
+ private updateSupergraphSdl;
27
+ private updateByComposition;
28
+ private createSupergraphFromServiceList;
29
+ private beginPolling;
30
+ private poll;
31
+ private logUpdateFailure;
32
+ }
33
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/supergraphManagers/LegacyFetcher/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAEnD,OAAO,EACL,iBAAiB,EACjB,wBAAwB,EACxB,oBAAoB,EAKrB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,8BAA8B,EAG/B,MAAM,OAAO,CAAC;AAIf,MAAM,WAAW,oBAAoB;IACnC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,wBAAwB,EAAE,8BAA8B,CAAC;IACzD,aAAa,EAAE,oBAAoB,CAAC;CACrC;AAOD,qBAAa,aAAc,YAAW,iBAAiB;IACrD,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,MAAM,CAAC,CAA8B;IAC7C,OAAO,CAAC,WAAW,CAAC,CAA8B;IAClD,OAAO,CAAC,aAAa,CAAC,CAAwB;IAC9C,OAAO,CAAC,QAAQ,CAA+B;IAC/C,OAAO,CAAC,KAAK,CAAQ;IACrB,OAAO,CAAC,aAAa,CAAC,CAAS;IAC/B,OAAO,CAAC,kBAAkB,CAAC,CAAsB;gBAErC,OAAO,EAAE,oBAAoB;IAMzC,OAAO,CAAC,wBAAwB;IAcnB,UAAU,CAAC,EACtB,MAAM,EACN,WAAW,EACX,aAAa,GACd,EAAE,wBAAwB;;;;YAuCb,mBAAmB;IAwBjC,OAAO,CAAC,mBAAmB;IA+B3B,OAAO,CAAC,+BAA+B;IA2BvC,OAAO,CAAC,YAAY;IAKpB,OAAO,CAAC,IAAI;IAqBZ,OAAO,CAAC,gBAAgB;CAMzB"}