rsnext/examples/api-routes-apollo-server-and-client
Horacio Valencia 081b8fba67
Updates Apollo Server Examples to use Apollo Server 4 & @as-integrations/next (#42771)
Closes https://github.com/vercel/next.js/issues/42769

## Description 

This PR address https://github.com/vercel/next.js/issues/42769 by updating the `api-routes-apollo-server`, `api-routes-apollo-server-and-client` and `api-routes-apollo-server-and-client-auth` examples to use Apollo Server 4 and [@as-integrations/next](https://github.com/apollo-server-integrations/apollo-server-integration-next), which is the Apollo Server Next integration package. The PR also updates the three examples to use Typescript. The functionality of the examples is the same.


## Documentation / Examples
- [X] Make sure the linting passes by running `pnpm build && pnpm lint`
- [X] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)


closes https://github.com/vercel/next.js/pull/33545
closes https://github.com/vercel/next.js/pull/30082
closes https://github.com/vercel/next.js/issues/21984
closes #10413
2022-11-14 12:13:31 +00:00
..
apollo Updates Apollo Server Examples to use Apollo Server 4 & @as-integrations/next (#42771) 2022-11-14 12:13:31 +00:00
pages Updates Apollo Server Examples to use Apollo Server 4 & @as-integrations/next (#42771) 2022-11-14 12:13:31 +00:00
.gitignore Update default gitignore templates (#39051) 2022-07-26 20:08:40 -05:00
package.json Updates Apollo Server Examples to use Apollo Server 4 & @as-integrations/next (#42771) 2022-11-14 12:13:31 +00:00
README.md Updates Apollo Server Examples to use Apollo Server 4 & @as-integrations/next (#42771) 2022-11-14 12:13:31 +00:00
tsconfig.json Updates Apollo Server Examples to use Apollo Server 4 & @as-integrations/next (#42771) 2022-11-14 12:13:31 +00:00

Apollo Server and Client Example

Apollo is a GraphQL client that allows you to easily query the exact data you need from a GraphQL server. In addition to fetching and mutating data, Apollo analyzes your queries and their results to construct a client-side cache of your data, which is kept up to date as further queries and mutations are run. The integration with Next and Apollo Server is implemented using the apollo-server-integration-next community package.

In this simple example, we integrate Apollo seamlessly with Next.js data fetching methods to fetch queries in the server and hydrate them in the browser.

Deploy your own

Deploy the example using Vercel or preview live with StackBlitz

Deploy with Vercel

How to use

Execute create-next-app with npm, Yarn, or pnpm to bootstrap the example:

npx create-next-app --example api-routes-apollo-server-and-client api-routes-apollo-server-and-client-app
yarn create next-app --example api-routes-apollo-server-and-client api-routes-apollo-server-and-client-app
pnpm create next-app --example api-routes-apollo-server-and-client api-routes-apollo-server-and-client-app

Deploy it to the cloud with Vercel (Documentation).