federation
federation copied to clipboard
Problem with field aliases when querying a subgraph schema created from a remote source
When trying to upgrade from:
- @apollo/federation: 0.14.1
- apollo-server: 2.25.3
to:
- @apollo/subgraph: 2.0.2
- apollo-server: 3.7.0
I seem to be running into an issue with field aliases. I am only experiencing this issue when creating a subgraph from a remote source. See the following example:
example (github):
https://github.com/alexander-aleman/subgraph-example In this example http://localhost:4000 will serve as the remote source for the subgraph on http://localhost:4001
tested with:
- NodeJS: v16.13.2
- NPM version: 8.3.1
environments:
http://localhost:4000/ http://localhost:4001/
Requests working on both environments:
request:
{
test {
nested {
structure
}
}
}
response
{
"data": {
"test": {
"nested": {
"structure": "here"
}
}
}
}
request:
{
a: test {
nested {
structure
}
}
}
response
{
"data": {
"a": {
"nested": {
"structure": "here"
}
}
}
}
Failing request:
request:
{
a: test {
b: nested {
c: structure
}
}
}
response from http://localhost:4000/ :
{
"data": {
"a": {
"b": {
"c": "here"
}
}
}
}
response from http://localhost:4001/ :
{
"errors": [
{
"message": "Cannot return null for non-nullable field NestedStructure.nested.",
"locations": [
{
"line": 3,
"column": 6
}
],
"path": [
"a",
"b"
],
"extensions": {
"code": "INTERNAL_SERVER_ERROR",
"exception": {
"stacktrace": [
"Error: Cannot return null for non-nullable field NestedStructure.nested.",
" at completeValue (/home/alexander/sites/apollo-subgraph-error/node_modules/graphql/execution/execute.js:592:13)",
" at executeField (/home/alexander/sites/apollo-subgraph-error/node_modules/graphql/execution/execute.js:487:19)",
" at executeFields (/home/alexander/sites/apollo-subgraph-error/node_modules/graphql/execution/execute.js:411:20)",
" at completeObjectValue (/home/alexander/sites/apollo-subgraph-error/node_modules/graphql/execution/execute.js:906:10)",
" at completeValue (/home/alexander/sites/apollo-subgraph-error/node_modules/graphql/execution/execute.js:633:12)",
" at completeValue (/home/alexander/sites/apollo-subgraph-error/node_modules/graphql/execution/execute.js:582:23)",
" at /home/alexander/sites/apollo-subgraph-error/node_modules/graphql/execution/execute.js:484:9",
" at processTicksAndRejections (node:internal/process/task_queues:96:5)",
" at async Promise.all (index 0)",
" at async execute (/home/alexander/sites/apollo-subgraph-error/node_modules/apollo-server-core/dist/requestPipeline.js:205:20)"
]
}
}
}
],
"data": null
}
Possibly related to https://github.com/ardatan/graphql-tools/issues/3267
Experiencing the same issue