Skip to content

Commit

Permalink
docs: Add note re: apollo-server-env` global removals to c-log/migrat…
Browse files Browse the repository at this point in the history
…ion guide (#5460)

Follows up on the release of Apollo Server 3 with changes from
#5165 which were
previously inadvertently omitted from both the Changelog and the migration
guide.
  • Loading branch information
abernix authored Jul 12, 2021
1 parent 699e70e commit 6ac0df7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ Certain undersupported and underused Apollo Server features have been removed in
- The `CacheHint` and `CacheScope` types are now exported from `apollo-server-types`. The `info.cacheControl.cacheHint` object now has additional methods (`replace`, `restrict`, and `policyIfCacheable`), and its fields update when those methods or `setCacheHint` are called. These methods also exist on `requestContext.overallCachePolicy`, which is always defined and which should not be overwritten (use `replace` instead). There is also a new function `info.cacheControl.cacheHintFromType` available.
- `@cacheControl` directives on type extensions are no longer ignored. Fields returning union types are now treated similarly to fields returning object and interface types (`@cacheControl` directives on the type are honored, the default `maxAge` is applied to them).
- New feature: `@cacheControl(inheritMaxAge: true)` when applied to a composite type or a field returning a composite type means that the default `maxAge` is not applied to that field (unless it is a root field).
- Due to conflicts with same/similar globals provided by `@types/supertest` (which we use in our testing), some global TypeScript definitions have been removed from `apollo-server-env` including that of, e.g., `fetch`, `RequestInfo`, `Headers`, `Request`, `Response`, `ResponseInit`, and more. [See the full list prior to removal here](https://github.com/apollographql/apollo-server/blob/32cfdcfdbd44f4f4e826f347f47fdcbc0475b5cc/packages/apollo-server-env/src/global.d.ts). Internally in the Apollo Server tests, for the time-being, we are relying on the same-named types from TypeScript's `lib.dom.d.ts` — e.g., [its `RequestInfo` type definition](https://github.com/microsoft/TypeScript/blob/3c604f1c0a412ef41f58c3f9b239b25e8d725751/lib/lib.dom.d.ts#L1470). For more details, [see PR #5165](https://github.com/apollographql/apollo-server/pull/5165).
- Top-level exports have changed. For example:
Expand Down
6 changes: 6 additions & 0 deletions docs/source/migration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,12 @@ class MyDataSource extends RESTDataSource {
}
```

### `apollo-server-env`'s global type definitions

Global TypeScript definitions have been removed from `apollo-server-env` since they conflicted with similar global types provided by `@types/supertest`, which we use in Apollo Server's test suite. These removed types include types which resemble those of [the Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) including, e.g., `fetch`, `RequestInfo`, `Headers`, `Request`, `Response`, `ResponseInit`, and more. [See the full list prior to removal here](https://github.com/apollographql/apollo-server/blob/32cfdcfdbd44f4f4e826f347f47fdcbc0475b5cc/packages/apollo-server-env/src/global.d.ts).

We don't expect this to affect many users and we have not publicly suggested using these types in the past, but it's possible that implementations may be using them inadvertently (e.g., from auto-import on `apollo-server-env`). While other type definition sets provide similar hand-curated types, for the time being, we have chosen to rely the same-named types from TypeScript's `lib.dom.d.ts` — e.g., [its `RequestInfo` type definition](https://github.com/microsoft/TypeScript/blob/3c604f1c0a412ef41f58c3f9b239b25e8d725751/lib/lib.dom.d.ts#L1470). Even if those types are more appropriate for browsers, they're a reliable and well-maintained source. For more details, including our plan for adjusting this again in the future, [see PR #5165](https://github.com/apollographql/apollo-server/pull/5165).

## Changed features

### Plugin API
Expand Down

0 comments on commit 6ac0df7

Please sign in to comment.