We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I was trying to update apollo-client from 3.6.10 to 3.7.0, and some tests started to fail.
Intended outcome:
Say I'm running ApolloClient in an express server, and want to forward cookies from the server request to ApolloClient's request.
module.exports = (app) => { app.get("/test", async (req, res, next) => { const client = createClient("https://example.com/graphql"); const result = await client.query({ query: query, context: { serverRequest: req, serverResponse: res } }); //... }); };
and I have a following custom ApolloLink implementation to forward cookie.
const headerForwardLink = () => { const link = new ApolloLink((operation, forward) => { operation.setContext(({ headers }) => { const serverRequest = operation.getContext().serverRequest; console.log( "headerForwardLink#user-agent", serverRequest.headers["user-agent"] ); console.log("headerForwardLink#cookie", serverRequest.headers.cookie); return { headers: { ...headers, "user-agent": serverRequest.headers["user-agent"], cookie: serverRequest.headers.cookie } }; }); return forward(operation).map((result) => { const response = operation.getContext().response; let setCookieHeader = response.headers.get("set-cookie"); if (setCookieHeader) { const serverResponse = operation.getContext().serverResponse; serverResponse.setHeader("set-cookie", setCookieHeader); } return result; }); }); return link; };
with 3.6.10, it works fine. console logs show cookie and user-agent from serverRequest, and it actually forward cookie and user-agent to ApolloClient.
Actual outcome:
Since 3.7.0, it no longer works. console logs shows undefined, and ApolloClient does not receive cookie from server request.
How to reproduce the issue:
https://github.com/yshrsmz/polloclient-context-test
run yarn install and yarn test to see it fails, and change apollo-client version to 3.6.10 and re-run yarn test. (sorry for the typo btw)
yarn install
yarn test
Versions
System: OS: macOS 12.6 Binaries: Node: 16.17.0 - ~/.anyenv/envs/nodenv/versions/16.17.0/bin/node Yarn: 1.22.19 - ~/.anyenv/envs/nodenv/versions/16.17.0/bin/yarn npm: 8.15.0 - ~/.anyenv/envs/nodenv/versions/16.17.0/bin/npm Browsers: Chrome: 105.0.5195.125 Safari: 16.0 npmPackages: @apollo/client: 3.7.0 => 3.7.0
The text was updated successfully, but these errors were encountered:
interesting note: serverRequest.headers is empty, but it seems like serverRequest.rawHeaders has raw values.
serverRequest.headers
serverRequest.rawHeaders
Sorry, something went wrong.
MrDoomBringer
Successfully merging a pull request may close this issue.
I was trying to update apollo-client from 3.6.10 to 3.7.0, and some tests started to fail.
Intended outcome:
Say I'm running ApolloClient in an express server, and want to forward cookies from the server request to ApolloClient's request.
and I have a following custom ApolloLink implementation to forward cookie.
with 3.6.10, it works fine.
console logs show cookie and user-agent from serverRequest, and it actually forward cookie and user-agent to ApolloClient.
Actual outcome:
Since 3.7.0, it no longer works. console logs shows undefined, and ApolloClient does not receive cookie from server request.
How to reproduce the issue:
https://github.com/yshrsmz/polloclient-context-test
run
yarn install
andyarn test
to see it fails, and change apollo-client version to 3.6.10 and re-runyarn test
.(sorry for the typo btw)
Versions
The text was updated successfully, but these errors were encountered: