@apollo/federation-internals 2.0.0-preview.9 → 2.0.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.
- package/CHANGELOG.md +25 -0
- package/dist/coreSpec.d.ts +1 -1
- package/dist/coreSpec.d.ts.map +1 -1
- package/dist/coreSpec.js +34 -11
- package/dist/coreSpec.js.map +1 -1
- package/dist/definitions.d.ts +20 -8
- package/dist/definitions.d.ts.map +1 -1
- package/dist/definitions.js +97 -58
- package/dist/definitions.js.map +1 -1
- package/dist/directiveAndTypeSpecification.d.ts.map +1 -1
- package/dist/directiveAndTypeSpecification.js +10 -1
- package/dist/directiveAndTypeSpecification.js.map +1 -1
- package/dist/error.d.ts +10 -0
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js +22 -2
- package/dist/error.js.map +1 -1
- package/dist/extractSubgraphsFromSupergraph.js +1 -1
- package/dist/extractSubgraphsFromSupergraph.js.map +1 -1
- package/dist/federation.d.ts +4 -1
- package/dist/federation.d.ts.map +1 -1
- package/dist/federation.js +33 -26
- package/dist/federation.js.map +1 -1
- package/dist/federationSpec.js +1 -1
- package/dist/federationSpec.js.map +1 -1
- package/dist/inaccessibleSpec.d.ts +7 -3
- package/dist/inaccessibleSpec.d.ts.map +1 -1
- package/dist/inaccessibleSpec.js +622 -32
- package/dist/inaccessibleSpec.js.map +1 -1
- package/dist/precompute.d.ts.map +1 -1
- package/dist/precompute.js +2 -2
- package/dist/precompute.js.map +1 -1
- package/dist/schemaUpgrader.d.ts.map +1 -1
- package/dist/schemaUpgrader.js +16 -5
- package/dist/schemaUpgrader.js.map +1 -1
- package/dist/supergraphs.d.ts.map +1 -1
- package/dist/supergraphs.js +1 -0
- package/dist/supergraphs.js.map +1 -1
- package/dist/validate.js +13 -7
- package/dist/validate.js.map +1 -1
- package/dist/values.d.ts +2 -2
- package/dist/values.d.ts.map +1 -1
- package/dist/values.js +13 -11
- package/dist/values.js.map +1 -1
- package/package.json +3 -3
- package/src/__tests__/coreSpec.test.ts +112 -0
- package/src/__tests__/removeInaccessibleElements.test.ts +2216 -177
- package/src/__tests__/subgraphValidation.test.ts +22 -5
- package/src/__tests__/values.test.ts +315 -3
- package/src/coreSpec.ts +70 -16
- package/src/definitions.ts +201 -83
- package/src/directiveAndTypeSpecification.ts +18 -1
- package/src/error.ts +62 -2
- package/src/extractSubgraphsFromSupergraph.ts +1 -1
- package/src/federation.ts +36 -26
- package/src/federationSpec.ts +2 -2
- package/src/inaccessibleSpec.ts +973 -55
- package/src/precompute.ts +2 -4
- package/src/schemaUpgrader.ts +25 -6
- package/src/supergraphs.ts +1 -0
- package/src/validate.ts +20 -9
- package/src/values.ts +39 -12
- package/tsconfig.test.tsbuildinfo +1 -1
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -3,6 +3,8 @@ import gql from "graphql-tag";
|
|
|
3
3
|
import { buildSubgraph } from "../federation";
|
|
4
4
|
import { errorCauses } from "../definitions";
|
|
5
5
|
import { assert } from "../utils";
|
|
6
|
+
import { buildSchemaFromAST } from "../buildSchema";
|
|
7
|
+
import { removeAllCoreFeatures } from "../coreSpec";
|
|
6
8
|
|
|
7
9
|
function expectErrors(
|
|
8
10
|
subgraphDefs: DocumentNode,
|
|
@@ -98,3 +100,113 @@ describe('@link(import:) argument', () => {
|
|
|
98
100
|
]);
|
|
99
101
|
});
|
|
100
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
|
+
});
|