#I'm not all the way there on that
1 messages · Page 1 of 1 (latest)
It doesn't have to. But lets say you have JS/TS code that is doing the work on the GraphQL server to return its results... if it was in a monorepo or accessible easily in a re-usable service, you could utilize that code directly on the Next.js server to get the data instead of calling across to another service.
If the GraphQL server exists purely to fetch data or handle requests from your front-end, there's also the option of Server Actions now.
Yeah so the server exists in a monorepo, how would I incorporate something like this? Are there existing patterns?
That is definitely the unfortunate bit right now in Next.js. Unless its a relatively simple service, its not trivial right now, one needs to use the experimental Instrumentation service to have a startup hook, and the experimentatl serverComponentsExternalPackages configuration setting to white-list Node only packages to ensure Nextjs doesn't try and bundle them for the client.
I still think you'd be better off using the new Next.js features to do the query on the server-side though for a faster first render. Note that Next.js has a separate Apollo Client for use in this manner: https://www.apollographql.com/blog/announcement/frontend/using-apollo-client-with-next-js-13-releasing-an-official-library-to-support-the-app-router/
Thank you for sharing this, I found the RFC to be an absolute 💎 of a read. Definitely adds additional context for me around more of the specifics of server and client components not to mention the need for this library. Again thanks, sounds as though you're at least marginally familiar with everything described here yourself so I hope it's no issue if I bug you later in the week about this if I have any questions? Nonetheless I appreciate the response.