@apollo/federation-internals 2.4.5 → 2.4.7

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/src/utils.ts CHANGED
@@ -401,7 +401,7 @@ export function printHumanReadableList(
401
401
  }
402
402
 
403
403
  export type Concrete<Type> = {
404
- [Property in keyof Type]-?: Type[Property];
404
+ [Property in keyof Type]-?: Concrete<Type[Property]>;
405
405
  };
406
406
 
407
407
  // for use with Array.filter
package/CHANGELOG.md DELETED
@@ -1,211 +0,0 @@
1
- # CHANGELOG for `@apollo/federation-internals`
2
-
3
- ## 2.4.5
4
- ### Patch Changes
5
-
6
-
7
- - Supersedes v2.4.4 due to a publishing error with no dist/ folder ([#2583](https://github.com/apollographql/federation/pull/2583))
8
-
9
- ## 2.4.4
10
-
11
- ## 2.4.3
12
- ### Patch Changes
13
-
14
-
15
- - Improves the heuristics used to try to reuse the query named fragments in subgraph fetches. Said fragment will be reused ([#2541](https://github.com/apollographql/federation/pull/2541))
16
- more often, which can lead to smaller subgraph queries (and hence overall faster processing).
17
-
18
- ## 2.4.2
19
- ### Patch Changes
20
-
21
-
22
- - Allow passing print options to the `compose` method to impact how the supergraph is printed, and adds new printing ([#2042](https://github.com/apollographql/federation/pull/2042))
23
- options to order all elements of the schema.
24
-
25
- - Fix potential bug when an `@interfaceObject` type has a `@requires`. When an `@interfaceObject` type has a field with a ([#2524](https://github.com/apollographql/federation/pull/2524))
26
- `@requires` and the query requests that field only for some specific implementations of the corresponding interface,
27
- then the generated query plan was sometimes invalid and could result in an invalid query to a subgraph (against a
28
- subgraph that rely on `@apollo/subgraph`, this lead the subgraph to produce an error message looking like `"The
29
- _entities resolver tried to load an entity for type X, but no object or interface type of that name was found in the
30
- schema"`).
31
-
32
- ## 2.4.1
33
- ### Patch Changes
34
-
35
-
36
- - Fix issues (incorrectly rejected composition and/or subgraph errors) with `@interfaceObject`. Those issues may occur ([#2494](https://github.com/apollographql/federation/pull/2494))
37
- either due to some use of `@requires` in an `@interfaceObject` type, or when some subgraph `S` defines a type that is an
38
- implementation of an interface `I` in the supergraph, and there is an `@interfaceObject` for `I` in another subgraph,
39
- but `S` does not itself defines `I`.
40
-
41
- - Fix assertion error during query planning in some cases where queries has some unsatisfiable branches (a part of the ([#2486](https://github.com/apollographql/federation/pull/2486))
42
- query goes through type conditions that no runtime types satisfies).
43
-
44
- - Start building packages with TS 5.x, which should have no effect on consumers ([#2480](https://github.com/apollographql/federation/pull/2480))
45
-
46
-
47
- - Improves reuse of named fragments in subgraph fetches. When a question has named fragments, the code tries to reuse ([#2497](https://github.com/apollographql/federation/pull/2497))
48
- those fragment in subgraph fetches is those can apply (so when the fragment is fully queried in a single subgraph fetch).
49
- However, the existing was only able to reuse those fragment in a small subset of cases. This change makes it much more
50
- likely that _if_ a fragment can be reused, it will be.
51
-
52
- ## 2.4.0
53
- ### Patch Changes
54
-
55
-
56
- - Refactor the internal implementation of selection sets used by the query planner to decrease the code complexity and ([#2387](https://github.com/apollographql/federation/pull/2387))
57
- improve query plan generation performance in many cases.
58
-
59
- - Revert #2293. Removing URL import causes a problem when running under deno. ([#2451](https://github.com/apollographql/federation/pull/2451))
60
-
61
-
62
- - Use globally available URL object instead of node builtin "url" module ([#2293](https://github.com/apollographql/federation/pull/2293))
63
-
64
-
65
- - Optimises query plan generation for parts of queries that can statically be known to not cross across subgraphs ([#2449](https://github.com/apollographql/federation/pull/2449))
66
-
67
- ## 2.4.0-alpha.1
68
- ### Patch Changes
69
-
70
-
71
- - Revert #2293. Removing URL import causes a problem when running under deno. ([#2451](https://github.com/apollographql/federation/pull/2451))
72
-
73
- ## 2.4.0-alpha.0
74
- ### Patch Changes
75
-
76
-
77
- - Handle defaulted variables correctly during post-processing. ([#2443](https://github.com/apollographql/federation/pull/2443))
78
-
79
- Users who tried to use built-in conditional directives (skip/include) with _defaulted_ variables and no variable provided would encounter an error thrown by operation post-processing saying that the variables weren't provided. The defaulted values went unaccounted for, so the operation would validate but then fail an assertion while resolving the conditional.
80
-
81
- With this change, defaulted variable values are now collected and provided to post-processing (with defaults being overwritten by variables that are actually provided).
82
-
83
-
84
- ## 2.3.5
85
-
86
- ## 2.3.4
87
- ### Patch Changes
88
-
89
- - Use globally available URL object instead of node builtin "url" module ([#2293](https://github.com/apollographql/federation/pull/2293))
90
-
91
- ## 2.3.3
92
-
93
- ## 2.3.2
94
-
95
- ## 2.3.1
96
-
97
- ## 2.3.0
98
-
99
- - Fix incorrect handling of `@external` on a type when dealing when adding `@shareable` during fed1 schema upgrades [PR #2343](https://github.com/apollographql/federation/pull/2343).
100
-
101
- ## 2.2.1
102
-
103
- - Fix federation spec always being expanded to the last version [PR #2274](https://github.com/apollographql/federation/pull/2274).
104
-
105
- ## 2.2.0
106
-
107
- - Preserve default values of input object fields [PR #2218](https://github.com/apollographql/federation/pull/2218).
108
- - Provide support for marking @external on object type [PR #2214](https://github.com/apollographql/federation/pull/2214)
109
- - Drop support for node12 [PR #2202](https://github.com/apollographql/federation/pull/2202)
110
- - Correctly reject field names starting with `__` [PR #2237](https://github.com/apollographql/federation/pull/2237).
111
- - Preserve default values of input object fields [PR #2218](https://github.com/apollographql/federation/pull/2218).
112
-
113
- ## 2.1.4
114
-
115
- - Ensures supergraph `@defer`/`@stream` definitions of supergraph are not included in the API schema [PR #2212](https://github.com/apollographql/federation/pull/2212).
116
- - Fix validation of variable on input field not taking default into account [PR #2176](https://github.com/apollographql/federation/pull/2176).
117
-
118
- ## 2.1.0
119
-
120
- - Update peer dependency `graphql` to `^16.5.0` to use `GraphQLErrorOptions` [PR #2060](https://github.com/apollographql/federation/pull/2060)
121
- - Don't require `@link` when using `@composeDirective` [PR #2046](https://github.com/apollographql/federation/pull/2046)
122
- - Add `@defer` support [PR #1958](https://github.com/apollographql/federation/pull/1958)
123
- - Add `@composeDirective` directive to specify directives that should be merged to the supergraph during composition [PR #1996](https://github.com/apollographql/federation/pull/1996).
124
- - Expand support for Node.js v18 [PR #1884](https://github.com/apollographql/federation/pull/1884)
125
-
126
- ## 2.0.4
127
-
128
- - Fix issue when all root operations were defined in an `extend schema` [PR #1875](https://github.com/apollographql/federation/issues/1875).
129
-
130
- ## 2.0.3
131
-
132
- - Fix bug with type extension of empty type definition [PR #1821](https://github.com/apollographql/federation/pull/1821)
133
-
134
- ## 2.0.2
135
-
136
- - Fix bug removing an enum type [PR #1813](https://github.com/apollographql/federation/pull/1813)
137
- - Fix `Schema.clone` when directive application happens before definition [PR #1785](https://github.com/apollographql/federation/pull/1785)
138
- - More helpful error message for errors encountered while reading supergraphs generated pre-federation 2 [PR #1796](https://github.com/apollographql/federation/pull/1796)
139
- - Fix bug applying an imported federation directive on another directive definition [PR #1797](https://github.com/apollographql/federation/pull/1797).
140
- - Prevent non-core-feature elements from being marked @inaccessible if referenced by core feature elements [PR #1769](https://github.com/apollographql/federation/pull/1769)
141
- - Improve fed1 schema support during composition [PR #1735](https://github.com/apollographql/federation/pull/1735)
142
- - Honor directive imports when directive name is spec name [PR #1720](https://github.com/apollographql/federation/pull/1720)
143
-
144
- ## v2.0.1
145
-
146
- - Use `for: SECURITY` in the core/link directive application in the supergraph for `@inaccessible` [PR #1715](https://github.com/apollographql/federation/pull/1715)
147
-
148
- ## v2.0.0
149
-
150
- - Previous preview release promoted to general availability! Please see previous changelog entries for full info.
151
-
152
- ## v2.0.0-preview.14
153
-
154
- - Implement `buildSubgraphSchema` using federation internals [PR #1697](https://github.com/apollographql/federation/pull/1697)
155
-
156
-
157
- ## v2.0.0-preview.11
158
-
159
- - Add support for `@inaccessible` v0.2 [PR #1678](https://github.com/apollographql/federation/pull/1678)
160
- - Add a level to hints, uppercase their code and related fixes [PR #1683](https://github.com/apollographql/federation/pull/1683).
161
-
162
- ## v2.0.0-preview.9
163
-
164
- - Adds Support for `@tag/v0.2`, which allows the `@tag` directive to be additionally placed on arguments, scalars, enums, enum values, input objects, and input object fields. [PR #1652](https://github.com/apollographql/federation/pull/1652).
165
- - Add missing `includeDeprecated` argument for `args` and `inputFields` when defining introspection fields [PR #1584](https://github.com/apollographql/federation/pull/1584)
166
- - Adds support for the `@override` directive on fields to indicate that a field should be moved from one subgraph to another. [PR #1484](https://github.com/apollographql/federation/pull/1484)
167
-
168
- ## v2.0.0-preview.5
169
-
170
- - Fix propagation of `@tag` to the supergraph and allows @tag to be repeated. Additionally, merged directives (only `@tag` and `@deprecated` currently) are not allowed on external fields anymore [PR #1592](https://github.com/apollographql/federation/pull/1592).
171
-
172
- ## v2.0.0-preview.4
173
-
174
- - Make error messages more actionable when constructing subgraphs from a supergraph [PR #1586](https://github.com/apollographql/federation/pull/1586)
175
-
176
- ## v2.0.0-preview.3
177
-
178
- - Fix issue that created type extensions with descriptions, which is invalid graphQL syntax [PR #1582](https://github.com/apollographql/federation/pull/1582).
179
-
180
- ## v2.0.0-preview.2
181
-
182
- - Re-publishing release which published to npm with stale build artifacts from `version-0.x` release.
183
-
184
- ## v2.0.0-preview.1
185
-
186
- - No-op publish to account for publishing difficulties.
187
-
188
- ## v2.0.0-preview.0
189
-
190
- - Initial "preview" release.
191
-
192
- ## v2.0.0-alpha.6
193
-
194
- - Avoid incomplete subgraphs when extracting them from the supergraph. [PR #1511](https://github.com/apollographql/federation/pull/1511)
195
-
196
- ## v2.0.0-alpha.5
197
-
198
- - Remove `graphql@15` from peer dependencies [PR #1472](https://github.com/apollographql/federation/pull/1472).
199
-
200
- ## v2.0.0-alpha.3
201
-
202
- - Assign and document error codes for all errors [PR #1274](https://github.com/apollographql/federation/pull/1274).
203
- - Fix issue reading some 0.x generated supergraphs [PR #1351](https://github.com/apollographql/federation/pull/1351).
204
-
205
- ## v2.0.0-alpha.2
206
-
207
- - __BREAKING__: Bump graphql peer dependency to `^15.7.0` [PR #1200](https://github.com/apollographql/federation/pull/1200)
208
-
209
- ## v2.0.0-alpha.1
210
-
211
- - :tada: Initial alpha release of Federation 2.0. For more information, see our [documentation](https://www.apollographql.com/docs/federation/v2/). We look forward to your feedback!
package/jest.config.js DELETED
@@ -1,11 +0,0 @@
1
- const baseConfig = require('../jest.config.base');
2
-
3
- /** @typedef {import('ts-jest/dist/types')} */
4
- /** @type {import('@jest/types').Config.InitialOptions} */
5
- module.exports = {
6
- ...baseConfig,
7
- displayName: {
8
- name: '@apollo/federation-internals',
9
- color: 'magenta'
10
- }
11
- };
@@ -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
- });