Skip to content

New Server Components NextJS~ How should we query our Server Within New Server Only Components #2093

Answered by n1ru4l
wakywayne asked this question in Q&A
Discussion options

You must be logged in to vote

There are multiple options available here:

Use fetch for loading data from the GraphQL API via HTTP

This is straightforward - you don't need a GraphQL client, it always depends on what you want to achieve. Executing a GraphQL operation can be as simple as doing an HTTP request with fetch.

This is best if your GraphQL Yoga HTTP server lives outside or alongside your Next.js Application as a separate service.

@notrab also made a video about Server Components and graphql-request, that would also be applicable here: https://graphql.wtf/episodes/66-graphql-with-nextjs-13-server-components

Use yoga.fetch for loading data without HTTP

You can actually use the following API for doing a GraphQL Yo…

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
2 replies
@wakywayne
Comment options

@wakywayne
Comment options

Comment options

You must be logged in to vote
1 reply
@wakywayne
Comment options

Answer selected by n1ru4l
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants