@apollo/federation-internals 2.4.4 → 2.4.6

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 (145) hide show
  1. package/dist/Subgraph.d.ts +1 -0
  2. package/dist/Subgraph.d.ts.map +1 -0
  3. package/dist/Subgraph.js +2 -0
  4. package/dist/Subgraph.js.map +1 -0
  5. package/dist/argumentCompositionStrategies.d.ts +34 -0
  6. package/dist/argumentCompositionStrategies.d.ts.map +1 -0
  7. package/dist/argumentCompositionStrategies.js +35 -0
  8. package/dist/argumentCompositionStrategies.js.map +1 -0
  9. package/dist/buildSchema.d.ts +10 -0
  10. package/dist/buildSchema.d.ts.map +1 -0
  11. package/dist/buildSchema.js +362 -0
  12. package/dist/buildSchema.js.map +1 -0
  13. package/dist/coreSpec.d.ts +127 -0
  14. package/dist/coreSpec.d.ts.map +1 -0
  15. package/dist/coreSpec.js +590 -0
  16. package/dist/coreSpec.js.map +1 -0
  17. package/dist/debug.d.ts +15 -0
  18. package/dist/debug.d.ts.map +1 -0
  19. package/dist/debug.js +122 -0
  20. package/dist/debug.js.map +1 -0
  21. package/dist/definitions.d.ts +663 -0
  22. package/dist/definitions.d.ts.map +1 -0
  23. package/dist/definitions.js +2841 -0
  24. package/dist/definitions.js.map +1 -0
  25. package/dist/directiveAndTypeSpecification.d.ts +67 -0
  26. package/dist/directiveAndTypeSpecification.d.ts.map +1 -0
  27. package/dist/directiveAndTypeSpecification.js +271 -0
  28. package/dist/directiveAndTypeSpecification.js.map +1 -0
  29. package/dist/error.d.ts +128 -0
  30. package/dist/error.d.ts.map +1 -0
  31. package/dist/error.js +315 -0
  32. package/dist/error.js.map +1 -0
  33. package/dist/extractSubgraphsFromSupergraph.d.ts +8 -0
  34. package/dist/extractSubgraphsFromSupergraph.d.ts.map +1 -0
  35. package/dist/extractSubgraphsFromSupergraph.js +576 -0
  36. package/dist/extractSubgraphsFromSupergraph.js.map +1 -0
  37. package/dist/federation.d.ts +175 -0
  38. package/dist/federation.d.ts.map +1 -0
  39. package/dist/federation.js +1414 -0
  40. package/dist/federation.js.map +1 -0
  41. package/dist/federationSpec.d.ts +25 -0
  42. package/dist/federationSpec.d.ts.map +1 -0
  43. package/dist/federationSpec.js +125 -0
  44. package/dist/federationSpec.js.map +1 -0
  45. package/dist/genErrorCodeDoc.d.ts +2 -0
  46. package/dist/genErrorCodeDoc.d.ts.map +1 -0
  47. package/dist/genErrorCodeDoc.js +61 -0
  48. package/dist/genErrorCodeDoc.js.map +1 -0
  49. package/dist/graphQLJSSchemaToAST.d.ts +8 -0
  50. package/dist/graphQLJSSchemaToAST.d.ts.map +1 -0
  51. package/dist/graphQLJSSchemaToAST.js +96 -0
  52. package/dist/graphQLJSSchemaToAST.js.map +1 -0
  53. package/dist/inaccessibleSpec.d.ts +18 -0
  54. package/dist/inaccessibleSpec.d.ts.map +1 -0
  55. package/dist/inaccessibleSpec.js +655 -0
  56. package/dist/inaccessibleSpec.js.map +1 -0
  57. package/dist/index.d.ts +24 -0
  58. package/dist/index.d.ts.map +1 -0
  59. package/dist/index.js +42 -0
  60. package/dist/index.js.map +1 -0
  61. package/dist/introspection.d.ts +6 -0
  62. package/dist/introspection.d.ts.map +1 -0
  63. package/dist/introspection.js +96 -0
  64. package/dist/introspection.js.map +1 -0
  65. package/dist/joinSpec.d.ts +51 -0
  66. package/dist/joinSpec.d.ts.map +1 -0
  67. package/dist/joinSpec.js +160 -0
  68. package/dist/joinSpec.js.map +1 -0
  69. package/dist/knownCoreFeatures.d.ts +5 -0
  70. package/dist/knownCoreFeatures.d.ts.map +1 -0
  71. package/dist/knownCoreFeatures.js +20 -0
  72. package/dist/knownCoreFeatures.js.map +1 -0
  73. package/dist/operations.d.ts +418 -0
  74. package/dist/operations.d.ts.map +1 -0
  75. package/dist/operations.js +2068 -0
  76. package/dist/operations.js.map +1 -0
  77. package/dist/precompute.d.ts +3 -0
  78. package/dist/precompute.d.ts.map +1 -0
  79. package/dist/precompute.js +54 -0
  80. package/dist/precompute.js.map +1 -0
  81. package/dist/print.d.ts +28 -0
  82. package/dist/print.d.ts.map +1 -0
  83. package/dist/print.js +299 -0
  84. package/dist/print.js.map +1 -0
  85. package/dist/schemaUpgrader.d.ts +121 -0
  86. package/dist/schemaUpgrader.d.ts.map +1 -0
  87. package/dist/schemaUpgrader.js +570 -0
  88. package/dist/schemaUpgrader.js.map +1 -0
  89. package/dist/suggestions.d.ts +3 -0
  90. package/dist/suggestions.d.ts.map +1 -0
  91. package/dist/suggestions.js +44 -0
  92. package/dist/suggestions.js.map +1 -0
  93. package/dist/supergraphs.d.ts +10 -0
  94. package/dist/supergraphs.d.ts.map +1 -0
  95. package/dist/supergraphs.js +76 -0
  96. package/dist/supergraphs.js.map +1 -0
  97. package/dist/tagSpec.d.ts +19 -0
  98. package/dist/tagSpec.d.ts.map +1 -0
  99. package/dist/tagSpec.js +66 -0
  100. package/dist/tagSpec.js.map +1 -0
  101. package/dist/types.d.ts +9 -0
  102. package/dist/types.d.ts.map +1 -0
  103. package/dist/types.js +64 -0
  104. package/dist/types.js.map +1 -0
  105. package/dist/utils.d.ts +64 -0
  106. package/dist/utils.d.ts.map +1 -0
  107. package/dist/utils.js +326 -0
  108. package/dist/utils.js.map +1 -0
  109. package/dist/validate.d.ts +4 -0
  110. package/dist/validate.d.ts.map +1 -0
  111. package/dist/validate.js +239 -0
  112. package/dist/validate.js.map +1 -0
  113. package/dist/validation/KnownTypeNamesInFederationRule.d.ts +4 -0
  114. package/dist/validation/KnownTypeNamesInFederationRule.d.ts.map +1 -0
  115. package/dist/validation/KnownTypeNamesInFederationRule.js +41 -0
  116. package/dist/validation/KnownTypeNamesInFederationRule.js.map +1 -0
  117. package/dist/values.d.ts +23 -0
  118. package/dist/values.d.ts.map +1 -0
  119. package/dist/values.js +580 -0
  120. package/dist/values.js.map +1 -0
  121. package/package.json +1 -1
  122. package/src/operations.ts +145 -20
  123. package/src/utils.ts +1 -1
  124. package/CHANGELOG.md +0 -205
  125. package/jest.config.js +0 -11
  126. package/src/__tests__/coreSpec.test.ts +0 -212
  127. package/src/__tests__/definitions.test.ts +0 -982
  128. package/src/__tests__/directiveAndTypeSpecifications.test.ts +0 -41
  129. package/src/__tests__/extractSubgraphsFromSupergraph.test.ts +0 -748
  130. package/src/__tests__/federation.test.ts +0 -31
  131. package/src/__tests__/graphQLJSSchemaToAST.test.ts +0 -156
  132. package/src/__tests__/matchers/index.ts +0 -1
  133. package/src/__tests__/matchers/toMatchString.ts +0 -87
  134. package/src/__tests__/operations.test.ts +0 -1266
  135. package/src/__tests__/removeInaccessibleElements.test.ts +0 -2471
  136. package/src/__tests__/schemaUpgrader.test.ts +0 -287
  137. package/src/__tests__/subgraphValidation.test.ts +0 -1254
  138. package/src/__tests__/supergraphSdl.graphql +0 -281
  139. package/src/__tests__/testUtils.ts +0 -28
  140. package/src/__tests__/toAPISchema.test.ts +0 -53
  141. package/src/__tests__/tsconfig.json +0 -7
  142. package/src/__tests__/utils.test.ts +0 -92
  143. package/src/__tests__/values.test.ts +0 -390
  144. package/tsconfig.json +0 -10
  145. package/tsconfig.test.json +0 -8
@@ -1,31 +0,0 @@
1
- import gql from "graphql-tag";
2
- import { buildSubgraph, federationMetadata } from "..";
3
-
4
- it("detects federation 1 subgraphs correctly", () => {
5
- const schema = gql`
6
- type Query {
7
- s: String
8
- }
9
- `;
10
-
11
- const subgraph = buildSubgraph('s', 's', schema);
12
- const metadata = federationMetadata(subgraph.schema);
13
- expect(metadata).toBeDefined();
14
- expect(metadata?.isFed2Schema()).toBeFalsy();
15
- });
16
-
17
- it("detects federation 2 subgraphs correctly", () => {
18
- const schema = gql`
19
- extend schema
20
- @link(url: "https://specs.apollo.dev/federation/v2.0")
21
-
22
- type Query {
23
- s: String
24
- }
25
- `;
26
-
27
- const subgraph = buildSubgraph('s', 's', schema);
28
- const metadata = federationMetadata(subgraph.schema);
29
- expect(metadata).toBeDefined();
30
- expect(metadata?.isFed2Schema()).toBeTruthy();
31
- });
@@ -1,156 +0,0 @@
1
- import {
2
- buildClientSchema,
3
- buildSchema,
4
- GraphQLSchema,
5
- introspectionFromSchema,
6
- print
7
- } from "graphql";
8
- import { graphQLJSSchemaToAST } from "../graphQLJSSchemaToAST";
9
- import './matchers';
10
-
11
- function validateRoundtrip(schemaStr: string, expectedWithoutASTNodes: string | undefined = schemaStr) {
12
- const schema = buildSchema(schemaStr);
13
- expect(print(graphQLJSSchemaToAST(schema))).toMatchString(schemaStr);
14
- if (expectedWithoutASTNodes) {
15
- expect(print(graphQLJSSchemaToAST(withoutASTNodes(schema)))).toMatchString(expectedWithoutASTNodes);
16
- }
17
- }
18
-
19
- function withoutASTNodes(schema: GraphQLSchema): GraphQLSchema {
20
- return buildClientSchema(introspectionFromSchema(schema));
21
- }
22
-
23
- it('round-trip for all type definitions', () => {
24
- const schema = `
25
- type Query {
26
- a: A
27
- b: B
28
- c: C
29
- d(arg: D): Int
30
- }
31
-
32
- interface I {
33
- x: Int
34
- }
35
-
36
- type A implements I {
37
- x: Int
38
- y: Int
39
- }
40
-
41
- union B = A | Query
42
-
43
- enum C {
44
- V1
45
- V2
46
- }
47
-
48
- input D {
49
- m: Int
50
- n: Int = 3
51
- }
52
- `;
53
-
54
- validateRoundtrip(schema);
55
- });
56
-
57
- it('round-trip with default arguments', () => {
58
- const schemaFct = (v: string) => `
59
- type Query {
60
- f(arg: V = ${v}): Int
61
- }
62
-
63
- input V {
64
- x: Int
65
- y: Int = 3
66
- }
67
- `;
68
-
69
- const schema = schemaFct('{x: 2}');
70
- // We go through introspection to ensure the AST nodes are
71
- // removed, but that also somehow expand default values (which is
72
- // fine, we just have to account for it in our assertion).
73
- const schemaWithDefaultExpanded = schemaFct('{x: 2, y: 3}');
74
-
75
- validateRoundtrip(schema, schemaWithDefaultExpanded);
76
- });
77
-
78
- it('round-trip for directive definitions and applications', () => {
79
- const directiveDefinitions = `directive @schemaDirective(v: Int!) on SCHEMA
80
-
81
- directive @typeDirective repeatable on OBJECT
82
-
83
- directive @fieldDirective(s: String, m: Int = 3) on FIELD_DEFINITION
84
- `;
85
-
86
- const schema = `
87
- schema @schemaDirective(v: 3) {
88
- query: Query
89
- }
90
-
91
- type Query @typeDirective @typeDirective {
92
- f: Int @fieldDirective(s: "foo")
93
- g: Int @deprecated
94
- }
95
-
96
- ${directiveDefinitions}
97
- `;
98
-
99
- // With the ast nodes removed, we lose custom directive applications
100
- const noApplications = `
101
- type Query {
102
- f: Int
103
- g: Int @deprecated
104
- }
105
-
106
- ${directiveDefinitions}
107
- `;
108
-
109
- validateRoundtrip(schema, noApplications);
110
- });
111
-
112
- it('round-trip with extensions', () => {
113
- const common = `scalar federation_FieldSet
114
-
115
- scalar link_Import
116
-
117
- directive @link(url: String!, import: link_Import) on SCHEMA
118
-
119
- directive @key(fields: federation_FieldSet) repeatable on OBJECT
120
- `;
121
-
122
- const schema = `
123
- extend schema @link(url: "https://specs.apollo.dev", import: ["@key"])
124
-
125
- type Query {
126
- t: T
127
- }
128
-
129
- type T
130
-
131
- extend type T @key(fields: "id") {
132
- id: ID!
133
- x: Int
134
- }
135
-
136
- ${common}
137
- `;
138
-
139
- // No AST means we lose both the directive applications, but also whether something is an
140
- // extension or not.
141
- const noAST = `
142
- type Query {
143
- t: T
144
- }
145
-
146
- type T {
147
- id: ID!
148
- x: Int
149
- }
150
-
151
- ${common}
152
- `;
153
-
154
- validateRoundtrip(schema, noAST);
155
- });
156
-
@@ -1 +0,0 @@
1
- import './toMatchString';
@@ -1,87 +0,0 @@
1
- // Make this file a module (See: https://github.com/microsoft/TypeScript/issues/17736)
2
- export {};
3
-
4
- // TODO: this is the same than in definition.test.ts. Could we move those to a common place (but is it worth having
5
- // a new module for that)? Maybe there is a better, more jest-native, way to do this.
6
- // Note(Sylvain): I initially added those because I didn't figure out a way to make `toMatchSnapshotInline` work
7
- // with strings cleanly: I always either ended up with indentation issuels, or the result looks very ugly in the
8
- // tests. But it could be I just don't understand well enough how it work.
9
- declare global {
10
- namespace jest {
11
- interface Matchers<R> {
12
- toMatchString(actual: string): R;
13
- toMatchStringArray(actual: string[]): R;
14
- }
15
- }
16
- }
17
-
18
- function deIndent(str: string): string {
19
- // Strip leading \n
20
- str = str.slice(str.search(/[^\n]/));
21
- // Strip trailing \n or space
22
- while (str.charAt(str.length - 1) === '\n' || str.charAt(str.length - 1) === ' ') {
23
- str = str.slice(0, str.length - 1);
24
- }
25
- const indent = str.search(/[^ ]/);
26
- return str
27
- .split('\n')
28
- .map(line => line.slice(indent))
29
- .join('\n');
30
- }
31
-
32
- expect.extend({
33
- toMatchString(expected: string, received: string) {
34
- received = deIndent(received);
35
- // If the expected string as a trailing '\n', add one since we removed it.
36
- if (expected.charAt(expected.length - 1) === '\n') {
37
- received = received + '\n';
38
- }
39
- const pass = this.equals(expected, received);
40
- const message = pass
41
- ? () => this.utils.matcherHint('toMatchString', undefined, undefined)
42
- + '\n\n'
43
- + `Expected: not ${this.printExpected(expected)}`
44
- : () => {
45
- return (
46
- this.utils.matcherHint('toMatchString', undefined, undefined,)
47
- + '\n\n'
48
- + this.utils.printDiffOrStringify(expected, received, 'Expected', 'Received', true));
49
- };
50
- return {received, expected, message, name: 'toMatchString', pass};
51
- },
52
-
53
- toMatchStringArray(expected: string[], received: string[]) {
54
- if (expected.length !== received.length) {
55
- const message = () =>
56
- this.utils.matcherHint('toMatchStringArray', undefined, undefined,)
57
- + `\n\nExpected an array of size ${expected.length} but got one of size ${received.length}\n\n`
58
- + this.utils.printDiffOrStringify(expected, received, 'Expected', 'Received', true);
59
- return {received, expected, message, name: 'toMatchStringArray', pass: false};
60
- }
61
-
62
- let pass = true;
63
- const messages: string[] = [];
64
- for (let i = 0; i < expected.length; i++) {
65
- const exp = expected[i];
66
- let rec = deIndent(received[i]);
67
- // If the expected string as a trailing '\n', add one since we removed it.
68
- if (exp.charAt(exp.length - 1) === '\n') {
69
- rec = rec + '\n';
70
- }
71
- if (!this.equals(exp, rec)) {
72
- pass = false;
73
- messages.push(
74
- `Elements at index ${i} do no match:\n`
75
- + this.utils.printDiffOrStringify(exp, rec, 'Expected', 'Received', true)
76
- );
77
- }
78
- }
79
- const message = () =>
80
- this.utils.matcherHint('toMatchString', undefined, undefined)
81
- + '\n\n'
82
- + (pass ? `Expected: not ${this.printExpected(expected)}` : messages.join('\n\n'));
83
-
84
- return {received, expected, message, name: 'toMatchStringArray', pass};
85
- }
86
- });
87
-