Search code examples
graphqlapollo

apollo graphql not receiving header info


I am using apollo, and sending query to the server. I can see the server response, and I am able to console.log the response even though the status is 204 with no content.

But why am I not getting any header information back?

This is my response when testing using my client.

Access-Control-Allow-Headers: content-type
Access-Control-Allow-Methods: GET,HEAD,PUT,PATCH,POST,DELETE
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 0
Date: Sun, 25 Nov 2018 04:02:47 GMT
Vary: Access-Control-Request-Headers
X-Powered-By: Express

But it works as normal in Postman:

X-Powered-By    Express
Access-Control-Allow-Origin *
Set-Cookie  accessToken=...; Max-Age=3000; Path=/; Expires=Sun, 25 Nov 2018 04:33:26 GMT; HttpOnly
Set-Cookie  refreshToken=...; Max-Age=3000; Path=/; Expires=Sun, 25 Nov 2018 04:33:26 GMT; HttpOnly
Content-Type    application/json; charset=utf-8
Content-Length  104
ETag    W/"68-5L4bPmWT9FPXmAdGj2wrUW6Ei/Y"
Date    Sun, 25 Nov 2018 03:43:26 GMT
Connection  keep-alive

Here is my server code:

const app = express();
app.use(cors());
app.use(logger('tiny'));
app.use(cookieParser());
app.use(
  '/api/graphql',
  expressGraphQL((req, res) => ({
    schema,
    graphiql: true,
    context: {
      req,
      res
    }
  }))
);
app.use(
  bodyParser.urlencoded({
    extended: true
  })
);
app.use(router);

Solution

  • In network tab, click on all instead of xhr