Closed alyavasilyeva closed 4 years ago
@alyavasilyeva - I actually just tested these changes with the next-apollo-example
and it seems these changes breaks ssr. Getting the following warnings: index.js:1 Warning: Expected server HTML to contain a matching <div> in <div>.
Here's how I'm passing in the client in the example:
const config = {
link: new HttpLink({
uri: "https://api.graph.cool/simple/v1/cixmkt2ul01q00122mksg82pn"
})
};
const client = new ApolloClient(config)
export default withData(client);
@adamsoffer oh, that's my mistake! I wrote a misleading description, at the moment it works like this:
const config = ctx => ({
link: new HttpLink({
uri: "https://api.graph.cool/simple/v1/cixmkt2ul01q00122mksg82pn",
headers: {
Cookie: !process.browser && ctx && ctx.req && ctx.req.headers['cookie'],
},
}),
});
export default withData(client);
This solution was enough for authentication in our project, and I didn't check it with ApolloClient, but if we still need to be able to use ApolloClient in withData, let me check it again!
Related to #60 If withData receives function, pass ctx to ApolloClient