@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.
- package/dist/Subgraph.d.ts +1 -0
- package/dist/Subgraph.d.ts.map +1 -0
- package/dist/Subgraph.js +2 -0
- package/dist/Subgraph.js.map +1 -0
- package/dist/argumentCompositionStrategies.d.ts +34 -0
- package/dist/argumentCompositionStrategies.d.ts.map +1 -0
- package/dist/argumentCompositionStrategies.js +35 -0
- package/dist/argumentCompositionStrategies.js.map +1 -0
- package/dist/buildSchema.d.ts +10 -0
- package/dist/buildSchema.d.ts.map +1 -0
- package/dist/buildSchema.js +362 -0
- package/dist/buildSchema.js.map +1 -0
- package/dist/coreSpec.d.ts +127 -0
- package/dist/coreSpec.d.ts.map +1 -0
- package/dist/coreSpec.js +590 -0
- package/dist/coreSpec.js.map +1 -0
- package/dist/debug.d.ts +15 -0
- package/dist/debug.d.ts.map +1 -0
- package/dist/debug.js +122 -0
- package/dist/debug.js.map +1 -0
- package/dist/definitions.d.ts +663 -0
- package/dist/definitions.d.ts.map +1 -0
- package/dist/definitions.js +2841 -0
- package/dist/definitions.js.map +1 -0
- package/dist/directiveAndTypeSpecification.d.ts +67 -0
- package/dist/directiveAndTypeSpecification.d.ts.map +1 -0
- package/dist/directiveAndTypeSpecification.js +271 -0
- package/dist/directiveAndTypeSpecification.js.map +1 -0
- package/dist/error.d.ts +128 -0
- package/dist/error.d.ts.map +1 -0
- package/dist/error.js +315 -0
- package/dist/error.js.map +1 -0
- package/dist/extractSubgraphsFromSupergraph.d.ts +8 -0
- package/dist/extractSubgraphsFromSupergraph.d.ts.map +1 -0
- package/dist/extractSubgraphsFromSupergraph.js +576 -0
- package/dist/extractSubgraphsFromSupergraph.js.map +1 -0
- package/dist/federation.d.ts +175 -0
- package/dist/federation.d.ts.map +1 -0
- package/dist/federation.js +1414 -0
- package/dist/federation.js.map +1 -0
- package/dist/federationSpec.d.ts +25 -0
- package/dist/federationSpec.d.ts.map +1 -0
- package/dist/federationSpec.js +125 -0
- package/dist/federationSpec.js.map +1 -0
- package/dist/genErrorCodeDoc.d.ts +2 -0
- package/dist/genErrorCodeDoc.d.ts.map +1 -0
- package/dist/genErrorCodeDoc.js +61 -0
- package/dist/genErrorCodeDoc.js.map +1 -0
- package/dist/graphQLJSSchemaToAST.d.ts +8 -0
- package/dist/graphQLJSSchemaToAST.d.ts.map +1 -0
- package/dist/graphQLJSSchemaToAST.js +96 -0
- package/dist/graphQLJSSchemaToAST.js.map +1 -0
- package/dist/inaccessibleSpec.d.ts +18 -0
- package/dist/inaccessibleSpec.d.ts.map +1 -0
- package/dist/inaccessibleSpec.js +655 -0
- package/dist/inaccessibleSpec.js.map +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +42 -0
- package/dist/index.js.map +1 -0
- package/dist/introspection.d.ts +6 -0
- package/dist/introspection.d.ts.map +1 -0
- package/dist/introspection.js +96 -0
- package/dist/introspection.js.map +1 -0
- package/dist/joinSpec.d.ts +51 -0
- package/dist/joinSpec.d.ts.map +1 -0
- package/dist/joinSpec.js +160 -0
- package/dist/joinSpec.js.map +1 -0
- package/dist/knownCoreFeatures.d.ts +5 -0
- package/dist/knownCoreFeatures.d.ts.map +1 -0
- package/dist/knownCoreFeatures.js +20 -0
- package/dist/knownCoreFeatures.js.map +1 -0
- package/dist/operations.d.ts +418 -0
- package/dist/operations.d.ts.map +1 -0
- package/dist/operations.js +2068 -0
- package/dist/operations.js.map +1 -0
- package/dist/precompute.d.ts +3 -0
- package/dist/precompute.d.ts.map +1 -0
- package/dist/precompute.js +54 -0
- package/dist/precompute.js.map +1 -0
- package/dist/print.d.ts +28 -0
- package/dist/print.d.ts.map +1 -0
- package/dist/print.js +299 -0
- package/dist/print.js.map +1 -0
- package/dist/schemaUpgrader.d.ts +121 -0
- package/dist/schemaUpgrader.d.ts.map +1 -0
- package/dist/schemaUpgrader.js +570 -0
- package/dist/schemaUpgrader.js.map +1 -0
- package/dist/suggestions.d.ts +3 -0
- package/dist/suggestions.d.ts.map +1 -0
- package/dist/suggestions.js +44 -0
- package/dist/suggestions.js.map +1 -0
- package/dist/supergraphs.d.ts +10 -0
- package/dist/supergraphs.d.ts.map +1 -0
- package/dist/supergraphs.js +76 -0
- package/dist/supergraphs.js.map +1 -0
- package/dist/tagSpec.d.ts +19 -0
- package/dist/tagSpec.d.ts.map +1 -0
- package/dist/tagSpec.js +66 -0
- package/dist/tagSpec.js.map +1 -0
- package/dist/types.d.ts +9 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +64 -0
- package/dist/types.js.map +1 -0
- package/dist/utils.d.ts +64 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +326 -0
- package/dist/utils.js.map +1 -0
- package/dist/validate.d.ts +4 -0
- package/dist/validate.d.ts.map +1 -0
- package/dist/validate.js +239 -0
- package/dist/validate.js.map +1 -0
- package/dist/validation/KnownTypeNamesInFederationRule.d.ts +4 -0
- package/dist/validation/KnownTypeNamesInFederationRule.d.ts.map +1 -0
- package/dist/validation/KnownTypeNamesInFederationRule.js +41 -0
- package/dist/validation/KnownTypeNamesInFederationRule.js.map +1 -0
- package/dist/values.d.ts +23 -0
- package/dist/values.d.ts.map +1 -0
- package/dist/values.js +580 -0
- package/dist/values.js.map +1 -0
- package/package.json +1 -1
- package/src/operations.ts +145 -20
- package/src/utils.ts +1 -1
- package/CHANGELOG.md +0 -205
- package/jest.config.js +0 -11
- package/src/__tests__/coreSpec.test.ts +0 -212
- package/src/__tests__/definitions.test.ts +0 -982
- package/src/__tests__/directiveAndTypeSpecifications.test.ts +0 -41
- package/src/__tests__/extractSubgraphsFromSupergraph.test.ts +0 -748
- package/src/__tests__/federation.test.ts +0 -31
- package/src/__tests__/graphQLJSSchemaToAST.test.ts +0 -156
- package/src/__tests__/matchers/index.ts +0 -1
- package/src/__tests__/matchers/toMatchString.ts +0 -87
- package/src/__tests__/operations.test.ts +0 -1266
- package/src/__tests__/removeInaccessibleElements.test.ts +0 -2471
- package/src/__tests__/schemaUpgrader.test.ts +0 -287
- package/src/__tests__/subgraphValidation.test.ts +0 -1254
- package/src/__tests__/supergraphSdl.graphql +0 -281
- package/src/__tests__/testUtils.ts +0 -28
- package/src/__tests__/toAPISchema.test.ts +0 -53
- package/src/__tests__/tsconfig.json +0 -7
- package/src/__tests__/utils.test.ts +0 -92
- package/src/__tests__/values.test.ts +0 -390
- package/tsconfig.json +0 -10
- package/tsconfig.test.json +0 -8
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
import { DocumentNode, GraphQLError } from "graphql";
|
|
2
|
-
import gql from "graphql-tag";
|
|
3
|
-
import { buildSubgraph } from "../federation";
|
|
4
|
-
import { assert } from "../utils";
|
|
5
|
-
import { buildSchemaFromAST } from "../buildSchema";
|
|
6
|
-
import { removeAllCoreFeatures } from "../coreSpec";
|
|
7
|
-
import { errorCauses } from "../error";
|
|
8
|
-
|
|
9
|
-
function expectErrors(
|
|
10
|
-
subgraphDefs: DocumentNode,
|
|
11
|
-
expectedErrorMessages: string[],
|
|
12
|
-
) {
|
|
13
|
-
let thrownError: Error | undefined = undefined;
|
|
14
|
-
expect(() => {
|
|
15
|
-
try {
|
|
16
|
-
// Note: we use buildSubgraph because currently it's the only one that does auto-magic import of
|
|
17
|
-
// directive definition, and we don't want to bother with adding the @link definition to every
|
|
18
|
-
// example.
|
|
19
|
-
buildSubgraph('S', '', subgraphDefs)
|
|
20
|
-
} catch (e) {
|
|
21
|
-
// Kind-of ugly, but if Jest has a better option, I haven't found it.
|
|
22
|
-
thrownError = e;
|
|
23
|
-
throw e;
|
|
24
|
-
}
|
|
25
|
-
}).toThrow(GraphQLError);
|
|
26
|
-
|
|
27
|
-
assert(thrownError, 'Should have thrown');
|
|
28
|
-
const causes = errorCauses(thrownError);
|
|
29
|
-
assert(causes, 'Should have some causes');
|
|
30
|
-
// Note: all the received message with start with "[S] <rest of message>", so the `slice` below
|
|
31
|
-
// strips the extra prefix. This avoid leaking the subgraph name to leak to the tests themselves.
|
|
32
|
-
expect(causes.map((e) => e.message.slice(4))).toStrictEqual(expectedErrorMessages);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
describe('@link(import:) argument', () => {
|
|
36
|
-
test('errors on misformed values', () => {
|
|
37
|
-
const schema = gql`
|
|
38
|
-
extend schema @link(
|
|
39
|
-
url: "https://specs.apollo.dev/federation/v2.0",
|
|
40
|
-
import: [
|
|
41
|
-
2,
|
|
42
|
-
{ foo: "bar" },
|
|
43
|
-
{ name: "@key", badName: "foo"},
|
|
44
|
-
{ name: 42 },
|
|
45
|
-
{ as: "bar" },
|
|
46
|
-
]
|
|
47
|
-
)
|
|
48
|
-
|
|
49
|
-
type Query {
|
|
50
|
-
q: Int
|
|
51
|
-
}
|
|
52
|
-
`;
|
|
53
|
-
|
|
54
|
-
expectErrors(schema, [
|
|
55
|
-
'Invalid sub-value 2 for @link(import:) argument: values should be either strings or input object values of the form { name: "<importedElement>", as: "<alias>" }.',
|
|
56
|
-
'Unknown field "foo" for sub-value {foo: "bar"} of @link(import:) argument.',
|
|
57
|
-
'Unknown field "badName" for sub-value {name: "@key", badName: "foo"} of @link(import:) argument.',
|
|
58
|
-
'Invalid value for the "name" field for sub-value {name: 42} of @link(import:) argument: must be a string.',
|
|
59
|
-
'Invalid sub-value {as: "bar"} for @link(import:) argument: missing mandatory "name" field.',
|
|
60
|
-
]);
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
test('errors on mismatch between name and alias', () => {
|
|
64
|
-
const schema = gql`
|
|
65
|
-
extend schema @link(
|
|
66
|
-
url: "https://specs.apollo.dev/federation/v2.0",
|
|
67
|
-
import: [
|
|
68
|
-
{ name: "@key", as: "myKey" },
|
|
69
|
-
{ name: "FieldSet", as: "@fieldSet" },
|
|
70
|
-
]
|
|
71
|
-
)
|
|
72
|
-
|
|
73
|
-
type Query {
|
|
74
|
-
q: Int
|
|
75
|
-
}
|
|
76
|
-
`;
|
|
77
|
-
|
|
78
|
-
expectErrors(schema, [
|
|
79
|
-
'Invalid @link import renaming: directive "@key" imported name should start with a \'@\' character, but got "myKey".',
|
|
80
|
-
'Invalid @link import renaming: type "FieldSet" imported name should not start with a \'@\' character, but got "@fieldSet" (or, if @FieldSet is a directive, then it should be referred to with a \'@\').',
|
|
81
|
-
]);
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
test('errors on importing unknown elements for known features', () => {
|
|
85
|
-
const schema = gql`
|
|
86
|
-
extend schema @link(
|
|
87
|
-
url: "https://specs.apollo.dev/federation/v2.0",
|
|
88
|
-
import: [ "@foo", "key", { name: "@sharable" } ]
|
|
89
|
-
)
|
|
90
|
-
|
|
91
|
-
type Query {
|
|
92
|
-
q: Int
|
|
93
|
-
}
|
|
94
|
-
`;
|
|
95
|
-
|
|
96
|
-
expectErrors(schema, [
|
|
97
|
-
'Cannot import unknown element "@foo".',
|
|
98
|
-
'Cannot import unknown element "key". Did you mean directive "@key"?',
|
|
99
|
-
'Cannot import unknown element "@sharable\". Did you mean "@shareable"?',
|
|
100
|
-
]);
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
describe('removeAllCoreFeatures', () => {
|
|
105
|
-
it('removes core (and only core) feature definitions, accounting for aliasing', () => {
|
|
106
|
-
const schema = buildSchemaFromAST(gql`
|
|
107
|
-
directive @lonk(url: String, as: String, for: Porpoise, import: [lonk__Import]) repeatable on SCHEMA
|
|
108
|
-
|
|
109
|
-
scalar lonk__Import
|
|
110
|
-
|
|
111
|
-
enum Porpoise {
|
|
112
|
-
"""
|
|
113
|
-
\`SECURITY\` features provide metadata necessary to securely resolve fields.
|
|
114
|
-
"""
|
|
115
|
-
SECURITY
|
|
116
|
-
|
|
117
|
-
"""
|
|
118
|
-
\`EXECUTION\` features provide metadata necessary for operation execution.
|
|
119
|
-
"""
|
|
120
|
-
EXECUTION
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
extend schema
|
|
124
|
-
@lonk(
|
|
125
|
-
url: "https://specs.apollo.dev/link/v1.0",
|
|
126
|
-
as: "lonk",
|
|
127
|
-
import: [
|
|
128
|
-
{ name: "Purpose", as: "Porpoise" }
|
|
129
|
-
]
|
|
130
|
-
)
|
|
131
|
-
@lonk(
|
|
132
|
-
url: "https://localhost/foobar/v1.0",
|
|
133
|
-
as: "foo"
|
|
134
|
-
import: [
|
|
135
|
-
"bar",
|
|
136
|
-
"@baz",
|
|
137
|
-
{ name: "qux", as: "qax" },
|
|
138
|
-
{ name: "@quz", as: "@qaz" },
|
|
139
|
-
]
|
|
140
|
-
)
|
|
141
|
-
|
|
142
|
-
type Query {
|
|
143
|
-
q: Int
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
# Shouldn't remove original spec name
|
|
147
|
-
scalar foobar
|
|
148
|
-
scalar foobar__Scalar
|
|
149
|
-
directive @foobar on FIELD
|
|
150
|
-
directive @foobar__directive on FIELD
|
|
151
|
-
|
|
152
|
-
# Should remove aliased spec name (other than type "foo")
|
|
153
|
-
scalar foo
|
|
154
|
-
scalar foo__Scalar
|
|
155
|
-
directive @foo on FIELD
|
|
156
|
-
directive @foo__directive on FIELD
|
|
157
|
-
|
|
158
|
-
# Should remove imports (prefixed or not)
|
|
159
|
-
type bar implements foo__bar {
|
|
160
|
-
someField: foo!
|
|
161
|
-
}
|
|
162
|
-
interface foo__bar {
|
|
163
|
-
someField: foo!
|
|
164
|
-
}
|
|
165
|
-
directive @baz on FIELD
|
|
166
|
-
directive @foo__baz on FIELD
|
|
167
|
-
|
|
168
|
-
# Shouldn't remove original import names
|
|
169
|
-
input qux {
|
|
170
|
-
someField: ID!
|
|
171
|
-
}
|
|
172
|
-
directive @quz on FIELD
|
|
173
|
-
|
|
174
|
-
# Should remove aliased import names (and prefixed original)
|
|
175
|
-
union qax = bar
|
|
176
|
-
enum foo__qax {
|
|
177
|
-
SOME_VALUE
|
|
178
|
-
}
|
|
179
|
-
scalar foo__qux
|
|
180
|
-
directive @qaz on FIELD
|
|
181
|
-
directive @foo__qaz on FIELD
|
|
182
|
-
directive @foo__quz on FIELD
|
|
183
|
-
`);
|
|
184
|
-
|
|
185
|
-
removeAllCoreFeatures(schema);
|
|
186
|
-
schema.validate();
|
|
187
|
-
|
|
188
|
-
expect(schema.elementByCoordinate("@lonk")).toBeUndefined();
|
|
189
|
-
expect(schema.elementByCoordinate("lonk__Import")).toBeUndefined();
|
|
190
|
-
expect(schema.elementByCoordinate("Porpoise")).toBeUndefined();
|
|
191
|
-
expect(schema.elementByCoordinate("foobar")).toBeDefined();
|
|
192
|
-
expect(schema.elementByCoordinate("foobar__Scalar")).toBeDefined();
|
|
193
|
-
expect(schema.elementByCoordinate("@foobar")).toBeDefined();
|
|
194
|
-
expect(schema.elementByCoordinate("@foobar__directive")).toBeDefined();
|
|
195
|
-
expect(schema.elementByCoordinate("foo")).toBeDefined();
|
|
196
|
-
expect(schema.elementByCoordinate("foo__Scalar")).toBeUndefined();
|
|
197
|
-
expect(schema.elementByCoordinate("@foo")).toBeUndefined();
|
|
198
|
-
expect(schema.elementByCoordinate("@foo__directive")).toBeUndefined();
|
|
199
|
-
expect(schema.elementByCoordinate("bar")).toBeUndefined();
|
|
200
|
-
expect(schema.elementByCoordinate("foo__bar")).toBeUndefined();
|
|
201
|
-
expect(schema.elementByCoordinate("@baz")).toBeUndefined();
|
|
202
|
-
expect(schema.elementByCoordinate("@foo__baz")).toBeUndefined();
|
|
203
|
-
expect(schema.elementByCoordinate("qux")).toBeDefined();
|
|
204
|
-
expect(schema.elementByCoordinate("@quz")).toBeDefined();
|
|
205
|
-
expect(schema.elementByCoordinate("qax")).toBeUndefined();
|
|
206
|
-
expect(schema.elementByCoordinate("foo__qax")).toBeUndefined();
|
|
207
|
-
expect(schema.elementByCoordinate("foo__qux")).toBeUndefined();
|
|
208
|
-
expect(schema.elementByCoordinate("@qaz")).toBeUndefined();
|
|
209
|
-
expect(schema.elementByCoordinate("@foo__qaz")).toBeUndefined();
|
|
210
|
-
expect(schema.elementByCoordinate("@foo__quz")).toBeUndefined();
|
|
211
|
-
});
|
|
212
|
-
});
|