-
Notifications
You must be signed in to change notification settings - Fork 26.8k
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
feat(examples): refactor api-routes-graphql
to GraphQL Yoga
#36155
feat(examples): refactor api-routes-graphql
to GraphQL Yoga
#36155
Conversation
GraphQL Yoga provides a more extensible (Envelop plugins](https://envelop.dev/)) and lighter bundle than the previously showcased `apollo-server-micro` ([64.5kB](https://bundlephobia.com/package/@graphql-yoga/node@2.2.1) vs [196.2kB](https://bundlephobia.com/package/apollo-server-micro@3.6.7) - min & GZiped) Similarly to Next.js, GraphQL Yoga comes with strong defaults and out of the box support for modern GraphQL features (File uploads, subscriptions, and more).
@@ -1,6 +1,24 @@ | |||
# API routes with GraphQL server | |||
|
|||
Next.js ships with [API routes](https://nextjs.org/docs/api-routes/introduction), which provide an easy solution to build your own `API`. This example shows their usage alongside [apollo-server-micro](https://github.com/apollographql/apollo-server/tree/main/packages/apollo-server-micro) to provide simple GraphQL server consumed by Next.js app. | |||
Next.js ships with [API routes](https://nextjs.org/docs/api-routes/introduction), which provide an easy solution to build your own `API`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a deployed example of this we can see?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, you'll find this branch deployed on Vercel here: https://api-routes-graphql-yoga.vercel.app/api/graphql?query=%7B%0A++greetings%0A%7D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@leerob did you had time to check the deployed version of it?
https://api-routes-graphql-yoga.vercel.app/api/graphql?query=%7B%0A++greetings%0A%7D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
…tNode` and GraphQL Yoga for better DX and smaller bundle size (#36240) Improve the Next.js with TypeScript + GraphQL example: - [x] use GraphQL Code Generator instead of `graphql-let`: more widespread tool and smaller bundle size (types only generation vs code generation) - [x] use GraphQL Yoga instead of Apollo Server Micro: for lighter bundle size as [stated here](#36155) - [x] introduces GraphQL Code Generator on the API side for Resolvers typing Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
GraphQL Yoga provides a more extensible experience (Envelop plugins) and lighter bundle than the previously showcased
apollo-server-micro
(64.5kB vs 196.2kB - min & GZiped)Similar to Next.js, GraphQL Yoga comes with strong defaults and out-of-the-box support for modern GraphQL features (File uploads, subscriptions, and more).
Strong of many years of existence and a large community, GraphQL Yoga 2.0 comes with Next.js support with no additional package or configuration 📦