Skip to content

Commit

Permalink
Merge branch 'master' into jsegaran/2020/1/duration_histogram
Browse files Browse the repository at this point in the history
  • Loading branch information
jsegaran authored Feb 5, 2020
2 parents 7ed47f9 + 21651bd commit f53e4ff
Show file tree
Hide file tree
Showing 9 changed files with 256 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ The version headers in this history reflect the versions of Apollo Server itself
- Move TContext generic from requestDidStart method to ApolloServerPlugin Interface [#3525](https://github.com/apollographql/apollo-server/pull/3525)
- `apollo-server-express`: Support `CorsOptionsDelegate` type on `cors` parameter to `applyMiddleware`, to align with the supported type of the underlying [`cors`](https://npm.im/cors) middleware [itself](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/31483b781ac30f98bdf4d40a517e921f2fc2ce37/types/cors/index.d.ts#L32). [PR #3613](https://github.com/apollographql/apollo-server/pull/3613)
- `apollo-server-core`: Allow asynchronous initialization of datasources: the `initialize` method on datasources may now return a Promise, which will be settled before any resolvers are called. [#3639](https://github.com/apollographql/apollo-server/pull/3639)
- `apollo-server-core`: experimental: Allow configuration of the parsed/validated document store by introducing an `experimental_approximateDocumentStoreMiB` property to the `ApolloServer` constructor options which overrides the default cache size of 30MiB. [#3755](https://github.com/apollographql/apollo-server/pull/3755)

### v2.9.16

Expand Down
223 changes: 212 additions & 11 deletions docs/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"serve": "gatsby serve"
},
"dependencies": {
"gatsby": "2.19.11",
"gatsby": "2.19.12",
"gatsby-theme-apollo-docs": "3.2.6",
"react": "16.12.0",
"react-dom": "16.12.0"
Expand Down
12 changes: 12 additions & 0 deletions docs/source/api/apollo-gateway.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,18 @@ example of using `ApolloGateway`, see [Implementing a federated graph](/federati
If `true`, the gateway logs startup messages, along with the query plan for
each incoming request. The default value is `false`.

* `experimental_approximateQueryPlanStoreMiB`: `number`

> **This property is experimental.** It may be removed or change at any time, even within a patch release.
When set, this sets the approximate size of the query plan store (in MiB).
This cache is used to save query plans for re-use on subsequent queries
which resolve to the same `queryHash` (a SHA-256 of incoming operation).

When this property is omitted, the cache is still enabled with a default
size of 30MiB, which is generally sufficient unless the server is
processing a high number of unique operations.

#### Returns

An `ApolloGateway` instance, which you then pass as the `gateway` configuration option to the `ApolloServer` constructor, like so:
Expand Down
13 changes: 13 additions & 0 deletions docs/source/api/apollo-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,19 @@ new ApolloServer({

Pass the integration-specific CORS options. `false` removes the CORS middleware and `true` uses the defaults. This option is only available to `apollo-server`. For other server integrations, place `cors` inside of `applyMiddleware`.

* `experimental_approximateDocumentStoreSizeMiB`: `number`

> **This property is experimental.** It may be removed or change at any time, even within a patch release.

When set, this sets the approximate size of the parsed/validated document
store (in MiB). This cache is used to save the already parsed and validated
`DocumentNode`s for re-use on subsequent queries which resolve to the same
`queryHash` (a SHA-256 of incoming operation).

When this property is omitted, the cache is still enabled with a default
size of 30MiB, which is generally sufficient unless the server is processing
a high number of unique operations.

#### Returns

`ApolloServer`
Expand Down
1 change: 1 addition & 0 deletions packages/apollo-gateway/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* Reduce interface expansion for types contained to a single service [#3582](https://github.com/apollographql/apollo-server/pull/3582)
* Instantiate one `CachedFetcher` per gateway instance. This resolves a condition where multiple federated gateways would utilize the same cache store could result in an `Expected undefined to be a GraphQLSchema` error. [#3704](https://github.com/apollographql/apollo-server/pull/3704)
* Gateway: minimize downstream request size [#3737](https://github.com/apollographql/apollo-server/pull/3737)
* experimental: Allow configuration of the query plan store by introducing an `experimental_approximateQueryPlanStoreMiB` property to the `ApolloGateway` constructor options which overrides the default cache size of 30MiB. [#3755](https://github.com/apollographql/apollo-server/pull/3755)

# v0.11.6

Expand Down
10 changes: 9 additions & 1 deletion packages/apollo-gateway/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ interface GatewayConfigBase {
experimental_updateServiceDefinitions?: Experimental_UpdateServiceDefinitions;
experimental_didUpdateComposition?: Experimental_DidUpdateCompositionCallback;
experimental_pollInterval?: number;
experimental_approximateQueryPlanStoreMiB?: number;
}

interface RemoteGatewayConfig extends GatewayConfigBase {
Expand Down Expand Up @@ -178,6 +179,8 @@ export class ApolloGateway implements GraphQLService {
// how often service defs should be loaded/updated (in ms)
protected experimental_pollInterval?: number;

private experimental_approximateQueryPlanStoreMiB?: number;

constructor(config?: GatewayConfig) {
this.config = {
// TODO: expose the query plan in a more flexible JSON format in the future
Expand Down Expand Up @@ -219,6 +222,9 @@ export class ApolloGateway implements GraphQLService {
this.experimental_didUpdateComposition =
config.experimental_didUpdateComposition;

this.experimental_approximateQueryPlanStoreMiB =
config.experimental_approximateQueryPlanStoreMiB;

if (
isManagedConfig(config) &&
config.experimental_pollInterval &&
Expand Down Expand Up @@ -609,7 +615,9 @@ export class ApolloGateway implements GraphQLService {
// only using JSON.stringify on the DocumentNode (and thus doesn't account
// for unicode characters, etc.), but it should do a reasonable job at
// providing a caching document store for most operations.
maxSize: Math.pow(2, 20) * 30,
maxSize:
Math.pow(2, 20) *
(this.experimental_approximateQueryPlanStoreMiB || 30),
sizeCalculator: approximateObjectSize,
});
}
Expand Down
Loading

0 comments on commit f53e4ff

Please sign in to comment.