-
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
Request: Support next.js 9.3 #114
Comments
There's no need for this package, or of any Apollo packages at all if you want to enjoy the goodies of the latest release of Next.js. For |
Ok thank you. I wasn't sure if the update would change anything with this package. Especially since its deprecates getInitialProps. Could be nice to mention in docs... But anyways thanks for responding! |
@LassiterJ |
add support with export const getServerSideProps = async ({ query, res }) => {
const { slug } = query;
if (!slug && res || slug.length < 2 && res) {
res.statusCode = 404
}
// it's necesary for display 404 custom error
const { data, error } = useQuery(MOVIE_SLUG, { variables: { slug } }); // not work....
if (data && data.movie === null) {
res.statusCode = 404;
}
...
}; |
@juanpablocs That is not how you suppose to use |
I imagine it would be difficult to make
Correct me if I am wrong @lfades |
This would be how we may use Apollo Client in Export
|
@hoangvvo You're not wrong, hence why we haven't updated the Apollo examples in the Next.js repo, but that surely will change with time, in the mean time is okay to use |
@lfades , have you tried using the beta version of the @apollo/client with nextjs 9.3+? |
I haven't, is there something new that requires an update? I still don't like the size of their package, keeps getting bigger: https://bundlephobia.com/result?p=@apollo/[email protected] 😨 |
I just tried it with Next 9.3 and it seems to work. I do see loading state for some of my content when I view source though - unsure if that is related? |
@wesbos going to try Next 9.3.5 / TS with this package. |
@wesbos SSR is now disabled by default unless you manually enable it by importing and adding export default withApollo(Index, { getDataFromTree }); |
Why are you disabling it by default? And does this lib mirror the official Thanks! |
@samuelcastro Feel free to use that example of this lib, you can't go wrong with either (I also helped trying to keep that example updated). SSR is disabled by default because static pages are faster, better overall, and more reliable, and can also be dynamic when you take advantage of SSG, it just happens that it's harder to do with the current state of the Apollo library. But that surely will be improved in the future. |
@lfades i've read: vercel/next.js#10930 (comment) |
@webcoderkz Not really, The reason I haven't migrated the library yet is because |
This question kind of extends beyond just the use of this library or Apollo, but I'm curious to know: is there a 'best practice' way to do what @juanpablocs mentioned above for dynamically returning a status code from the server using Apollo? I want to return an appropriate status code from the server based on what exists in a CMS and could just use fetch, but I would like to keep Apollo in some places in order to |
After a few hours trying to make this work with |
@charliedieter Why do you need to return a status code from the server to the client? what value is that providing for cases where it's not an error? Overall I would like to just completely change the implementation of Apollo in the Next.js examples as it keeps breaking constantly for some reason 😢 |
In my case, I have a CMS backend where content creators can build pages with a pathname. So if you go to |
Looks like it is related. I'm having the same issue. When viewing source I see the loading state. |
I'm trying to make
This worked for me. Just in case if anyone is looking. |
@SoorajChandran |
Note: SSR may not be entirely working, see lfades/next-with-apollo#114
@SoorajChandran hi const response = await apolloClient.query({
query: USER_QUERY,
variables: { userName: context.params?.userId },
}) i want to query, variables type checking |
I'm currently evaluating the options to move from |
Would like an update for the new version of next.js. Specifically including the new data-fetching methods and examples of use.
The text was updated successfully, but these errors were encountered: