You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If such field with arguments is used in a @requires, then that @requires
must provide a value for any required argument and may provide a value
for any non-required one (like in any normal graphQL selection set).
Additionally, this commit rejects aliases in @requires, @provides and
@key. Not because aliases cannot ever make sense in those directives,
but rather because it currently does not work (it breaks at runtime) but
wasn't rejected properly.
Fixes#1987
Copy file name to clipboardExpand all lines: composition-js/CHANGELOG.md
+2
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,8 @@
2
2
3
3
This CHANGELOG pertains only to Apollo Federation packages in the 2.x range. The Federation v0.x equivalent for this package can be found [here](https://github.com/apollographql/federation/blob/version-0.x/federation-js/CHANGELOG.md) on the `version-0.x` branch of this repo.
4
4
5
+
- Allow fields with arguments in `@requires`[PR #2120](https://github.com/apollographql/federation/pull/2120).
6
+
5
7
## 2.1.0
6
8
7
9
- Don't apply @shareable when upgrading fed1 supergraphs if it's already @shareable[PR #2043](https://github.com/apollographql/federation/pull/2043)
'Argument "Query.q(a:)" is required in some subgraphs but does not appear in all subgraphs: it is required in subgraph "subgraphA" but does not appear in subgraph "subgraphB"']
1530
1530
]);
1531
1531
});
1532
+
1533
+
it('errors if a subgraph argument is "@required" without arguments but that argument is mandatory in the supergraph',()=>{
'[subgraphA] On field "T.y", for @requires(fields: "x"): no value provided for argument "arg" of field "T.x" but a value is mandatory as "arg" is required in subgraph "subgraphB"',
1566
+
]
1567
+
]);
1568
+
});
1569
+
1570
+
it('errors if a subgraph argument is "@required" with an argument, but that argument is not in the supergraph',()=>{
'[subgraphA] On field "T.y", for @requires(fields: "x(arg: 42)"): cannot provide a value for argument "arg" of field "T.x" as argument "arg" is not defined in subgraph "subgraphB"',
(incompatibleSubgraphs)=>`cannot provide a value for argument "${arg}" of field "${field}" as argument "${arg}" is not defined in ${incompatibleSubgraphs}`,
(incompatibleSubgraphs)=>`no value provided for argument "${arg}" of field "${field}" but a value is mandatory as "${arg}" is required in ${incompatibleSubgraphs}`,
2213
+
);
2214
+
continue;
2215
+
}
2216
+
2217
+
assert(false,()=>`Unexpected error throw by ${requiresApplication} when evaluated on supergraph: ${e.message}`);
Copy file name to clipboardExpand all lines: docs/source/errors.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -76,7 +76,6 @@ The following errors might be raised during composition:
76
76
|`REQUIRED_INACCESSIBLE`| An element is marked as @inaccessible but is required by an element visible in the API schema. | 2.0.0 ||
77
77
|`REQUIRED_INPUT_FIELD_MISSING_IN_SOME_SUBGRAPH`| A field of an input object type is mandatory in some subgraphs, but the field is not defined in all the subgraphs that define the input object type. | 2.0.0 ||
78
78
|`REQUIRES_DIRECTIVE_IN_FIELDS_ARG`| The `fields` argument of a `@requires` directive includes some directive applications. This is not supported | 2.1.0 ||
79
-
|`REQUIRES_FIELDS_HAS_ARGS`| The `fields` argument of a `@requires` directive includes a field defined with arguments (which is not currently supported). | 2.0.0 ||
80
79
|`REQUIRES_FIELDS_MISSING_EXTERNAL`| The `fields` argument of a `@requires` directive includes a field that is not marked as `@external`. | 0.x ||
81
80
|`REQUIRES_INVALID_FIELDS_TYPE`| The value passed to the `fields` argument of a `@requires` directive is not a string. | 2.0.0 ||
82
81
|`REQUIRES_INVALID_FIELDS`| The `fields` argument of a `@requires` directive is invalid (it has invalid syntax, includes unknown fields, ...). | 2.0.0 ||
@@ -116,6 +115,7 @@ The following error codes have been removed and are no longer generated by the m
116
115
|`NON_REPEATABLE_DIRECTIVE_ARGUMENTS_MISMATCH`| Since federation 2.1.0, the case this error used to cover is now a warning (with code `INCONSISTENT_NON_REPEATABLE_DIRECTIVE_ARGUMENTS`) instead of an error |
117
116
|`PROVIDES_FIELDS_SELECT_INVALID_TYPE`|@provides can now be used on field of interface, union and list types |
118
117
|`PROVIDES_NOT_ON_ENTITY`|@provides can now be used on any type. |
118
+
|`REQUIRES_FIELDS_HAS_ARGS`| Since federation 2.1.1, using fields with arguments in a @requires is fully supported |
119
119
|`REQUIRES_FIELDS_MISSING_ON_BASE`| Fields in @requires can now be from any subgraph. |
120
120
|`REQUIRES_USED_ON_BASE`| As there is not type ownership anymore, there is also no particular limitation as to which subgraph can use a @requires. |
121
121
|`RESERVED_FIELD_USED`| This error was previously not correctly enforced: the _service and _entities, if present, were overridden; this is still the case |
0 commit comments