-
Notifications
You must be signed in to change notification settings - Fork 79
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
How to implement next-with-apollo with react-apollo SSR? #58
Comments
Hi @kumarabhirup, is this example from the post not working for you ? import withApollo from 'next-with-apollo'
import ApolloClient from 'apollo-boost'
function createClient({ headers }) {
return new ApolloClient({
uri: `${process.env.ENDPOINT}/graphql`,
request: operation => {
operation.setContext({
fetchOptions: {
credentials: 'include',
},
headers
})
}
})
}
export default withApollo(createClient) |
No that wouldn't, because I also need Please help 🙏 |
@kumarabhirup Then add them, it should work, if you get an error please create a reproduction so I can take a look 👍 |
Now I get Here's the GitHub repo: https://github.com/KumarAbhirup/paprink/tree/noLagOnProdPlease |
I think we need some change in the
Error's coming because the code above isn't complying with what |
I tried using
|
In my case, headers were found in |
Hey, I tried that and it is retreiving cookies and works fine. BUT... now it is no more Server Side Rendered! It now shows |
@kumarabhirup Did you fix it by creating your own version of the package ? btw you're missing |
Hey, what do you mean by creating "own version of package"? Can you please check the code in my backend? May be the way I save cookie be wrong? I tried my best, but I feel everything's matching the |
@kumarabhirup The backend has nothing to do here, as long as the cookie is set and you can see it devtools then the client should take care of it |
So, why is it that everytime I use When SSR doesn't work, a loading text appears everywhere but then cookies and auth token is rendered. What must be the issue? On client side, |
@kumarabhirup I don't really know why but here are some solutions:
Always remember that I'm going to close this issue for now because it's not related to this package, I hope you solve it 🙏 |
* 📦 NEW: Introduce implementation of apollo SSR See: https://github.com/zeit/next.js/tree/master/examples/with-apollo Referencing #35 * 👌 IMPROVE: Remove useless code * 👌 IMPROVE: Remove useless code * ❎ SAVE: Add headers code HAS BUGS * ❎ SAVE: Use headers * ❎ SAVE: Show for an issue lfades/next-with-apollo#58 * ❎ SAVE: Just save what's working * ❎ SAVE: Copy-Paste code from https://github.com/zeit/next.js/blob/canary/examples/with-apollo-auth/lib/withApollo.js * ❎ SAVE: Try more not cry * ❎ SAVE: Remove request functions * 📦 NEW: Code checkLoggedIn and redirect script Imported (copied) from https://github.com/zeit/next.js/tree/canary/examples/with-apollo-auth * 👌 IMPROVE: Use checkLoggedIn in _app * ❎ SAVE: Abandon! * ❎ SAVE: Remove console logs * 👌 IMPROVE: Add await in _app.js * 👌 IMPROVE: revert to with-apollo-auth original eg * 🐛 FIX: fix SSR (#38) Thanks Harshit Pant * 👌 IMPROVE: Update lock * 👌 IMPROVE: gitignore .env.production * 📦 NEW: Use dep remover * 🚀 IT WORKS!
Now in 2020, when I use hooks, it turns out the problem isn't solved with Next.js 9. But it only renders on the Client Side. I think we should reopen this issue. |
I am using |
I am using
react-apollo
withNext.js
the way it is illustrated in the example from the Next.js repo.Complete question detail on Spectrum Next.js community.
The text was updated successfully, but these errors were encountered: