Skip to content

Commit 659785a

Browse files
authored
Add note about migrating from AS2 to 3 (#7146)
Add note about migrating from AS2 to 3 and my linter removed some extra whitespace.
1 parent 38ce813 commit 659785a

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

docs/source/deployment/azure-functions.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ Now return to the base folder and run the `func host start` command again:
152152
func host start
153153
```
154154

155-
Apollo Server should now be up and running! If you go back to your browser (to either [http://localhost:7071/api/graphql?name=Apollo](http://localhost:7071/api/graphql?name=Apollo) or your custom URL path) and refresh, you can now open up [Apollo Sandbox](../testing/build-run-queries/#apollo-sandbox) and run operations against your server.
155+
Apollo Server should now be up and running! If you go back to your browser (to either [http://localhost:7071/api/graphql?name=Apollo](http://localhost:7071/api/graphql?name=Apollo) or your custom URL path) and refresh, you can now open up [Apollo Sandbox](../workflow/build-run-queries) and run operations against your server.
156156

157157
## Deploying with the Azure CLI
158158

docs/source/migration.mdx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ Apollo Server 4 provides the following features:
1818
1919
## The new `@apollo/server` package
2020

21+
> 🚚 This guide helps you migrate from Apollo Server 3 to Apollo Server 4. If you are using Apollo Server 2, you must first [migrate to Apollo Server 3](https://www.apollographql.com/docs/apollo-server/v3/migration) before following this guide.
22+
2123
Apollo Server 3 is distributed as a [fixed set of packages](/apollo-server/v3/integrations/middleware) for integrating with different web frameworks and environments. The main "batteries-included" [`apollo-server` package](/apollo-server/v3/integrations/middleware#apollo-server) reduces setup time by providing a minimally customizable GraphQL server.
2224

2325
In Apollo Server 3, the `apollo-server-core` package defines an `ApolloServer` "base" class, which each integration package (`apollo-server-express`,`apollo-server-lambda`, etc.) subclasses with a slightly different API. This packaging structure means that new integration package releases are lockstep versioned to Apollo Server itself, making it challenging to support major versions of frameworks and add integration-specific changes. Additionally, Apollo Server 3 doesn't provide a way to add new integrations for additional frameworks.
@@ -365,7 +367,7 @@ The following `ApolloServer` constructor options have been removed in favor of o
365367

366368
### `dataSources`
367369

368-
> 📣 See our new [Fetching Data](./data/fetching-data) article for more information on how the _concept_ of a data source has changed in Apollo Sever 4.
370+
> 📣 See our new [Fetching Data](./data/fetching-data) article for more information on how the _concept_ of a data source has changed in Apollo Sever 4.
369371
370372
In Apollo Server 3, the top-level [`dataSources` constructor option](/apollo-server/v3/data/data-sources#adding-data-sources-to-apollo-server) essentially adds a post-processing step to your app's context function, creating `DataSource` subclasses and adding them to a `dataSources` field on your [`context`](./data/resolvers/#the-context-argument) object. This means the TypeScript type the `context` function returns is _different_ from the `context` type your resolvers and plugins receive. Additionally, this design obfuscates that `DataSource` objects are created once per request (i.e., like the rest of the context object).
371373

@@ -382,7 +384,7 @@ import { RESTDataSource, RequestOptions } from 'apollo-datasource-rest';
382384
import { ApolloServer } from 'apollo-server';
383385

384386
// highlight-start
385-
class MoviesAPI extends RESTDataSource {
387+
class MoviesAPI extends RESTDataSource {
386388
// highlight-end
387389
override baseURL = 'https://movies-api.example.com/';
388390

@@ -414,7 +416,7 @@ const server = new ApolloServer({
414416
typeDefs,
415417
resolvers,
416418
//highlight-start
417-
context: ({ req: ExpressRequest }): Omit<ContextValue, 'dataSources'> => {
419+
context: ({ req: ExpressRequest }): Omit<ContextValue, 'dataSources'> => {
418420
//highlight-end
419421
return {
420422
token: getTokenFromRequest(req),
@@ -471,12 +473,12 @@ class MoviesAPI extends RESTDataSource { // highlight-line
471473
}
472474
}
473475
// highlight-start
474-
interface ContextValue {
475-
token: string;
476-
dataSources: {
477-
moviesAPI: MoviesAPI;
478-
};
479-
}
476+
interface ContextValue {
477+
token: string;
478+
dataSources: {
479+
moviesAPI: MoviesAPI;
480+
};
481+
}
480482
// highlight-end
481483

482484
const server = new ApolloServer<ContextValue>({

0 commit comments

Comments
 (0)