Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data is getting set null when errors come from stitched remote schemas #4063

Open
Tracked by #5201 ...
suwigyarathore opened this issue Dec 31, 2021 Discussed in #4056 · 0 comments
Open
Tracked by #5201 ...

Data is getting set null when errors come from stitched remote schemas #4063

suwigyarathore opened this issue Dec 31, 2021 Discussed in #4056 · 0 comments
Assignees

Comments

@suwigyarathore
Copy link

suwigyarathore commented Dec 31, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants