Repository navigation
Replies: 6 comments 17 replies
|
Here's a minimal example for fetching a GraphQL API: https://github.com/zeit/next.js/blob/canary/examples/cms-datocms/lib/api.js#L23-L42 The way that Apollo does tree-rendering to allow useQuery causes quite a lot of performance overhead (and general bundle size when using Apollo is quite heavy currently). So would recommend using a lightweight solution. Using the plain Apollo client without |
|
Hi, |
|
Anyone figure this out with Apollo? Specifically, SSR with client side querying of the Apollo store: e.g. loading posts (server side with getServerSideProps) with client side paging. @timneutkens I checked out the example above, but to your point, it doesn't really fit the use case. The example makes fetch requests, then relies on props drilling versus reading from and updating the Apollo store. This one's been killin' me. |
works for me. |
|
Here is an example #13202 if you want to query your API route GraphQL endpoint in order to do Static Generation with |
|
I had a similar issue, was getting "XMLHttpRequest is not defined". My problem was that I was using unfetch instead of fetch and didn't remove it in getStaticProps |
Uh oh!
There was an error while loading. Please reload this page.
Hey! π
Thanks for releasing NextJS 9.3! Although it's only a minor version bump, it's definitely a major step forward!
Unfortunately, I couldn't find any example/docs which demonstrates how to call a GraphQL API either in
getStaticPropsorgetServerSideProps. This could be using one of the popular clients such as Apollo Client, urql, React Query, etc.. Currently we're using the next-with-apollo package which (as far as I know) basically wrapsgetInitialPropsand enables to useuseQueryoruseMutationhooks in your components. Is there an equivalent solution or workaround which supports the newly released APIs?All reactions