-
-
Notifications
You must be signed in to change notification settings - Fork 831
Description
Discussed in #4056
Originally posted by guifeliper December 27, 2021
Setup:
We have the following code for stitching the remote schemas; they are perfectly working.
const makeGatewaySchema = async () => {
return stitchSchemas({
subschemas: [
{
schema: await introspectSchema(remoteExecutorA, baseContext),
executor: remoteExecutorA,
},
{
schema: await introspectSchema(remoteExecutorB, baseContext),
executor: remoteExecutorB,
},
],
}):
}
const runServer = async () => {
const schema = await makeGatewaySchema();
const app = express();
app.use(
'/',
graphqlHTTP(() => ({
schema,
graphiql: true,
}))
);
let { PORT } = process.env;
PORT = PORT || '3333';
app.listen(PORT, () => {
console.log(`Listening on http://localhost:${PORT}`);
});
};
https://www.graphql-tools.com/docs/remote-schemas
Scenario 1:
The response from one of the stitched graphql endpoint has error and data, the data on the client-side is returned as null, and the error has its message aggregated. However, a simple console.log on remote executor shows us that we have data and more than one error coming from the underlying subschema. Here is the current response on the client-side:
{
"errors":[
{
"message":"Account <###@###.com> not found, \nAccount <###@###.com> not found",
"path":[
"organization"
]
}
],
"data":{
"organization":null
}
}
The following response shows us what we receive from the remote executor.
{
"errors":[
{
"message":"Account <###@###.com> not found",
"path":[
"Array"
],
"extensions":[
"Object"
]
},
{
"message":"Account <###@###.com> not found",
"path":[
"Array"
],
"extensions":[
"Object"
]
}
],
"data":{
"__typename":"Query",
"organization":{
"accounts":[
"Array"
],
"__typename":"Organization"
}
}
}
Scenario 2:
The query has errors and no data. The response on the client-side receives a 500 network error. The following response shows us what we receive from the remote executor.
{
"errors":[
{
"message":"Account <###@###.com> not found",
"path":[
"Array"
],
"extensions":[
"Object"
]
},
{
"message":"Account <###@###.com> not found",
"path":[
"Array"
],
"extensions":[
"Object"
]
}
],
"data": null
}
}
Expectations
The data and error should be preserved as it is and should be passed to the client unmodified.