-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Only pass specific
persistedQueries
properties on `GraphQLServiceCo…
…ntext`. The `persistedQueries` attribute on the GraphQLServiceContext was originally used by the operation registry, which shared the cache with it. This is no longer the case. However, while we are continuing to expand the support of the interface for `persistedQueries`, e.g. support for default TTL values on APQ cache in #3623, we don't want to continually expand the API surface of what we expose to the plugin API as we're intending to deprecate its exposure in the future. In this particular case, it certainly doesn't need to get the `ttl` default values which are intended for APQ only.
- Loading branch information
Showing
1 changed file
with
29 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,10 @@ import { | |
InMemoryLRUCache, | ||
PrefixingKeyValueCache, | ||
} from 'apollo-server-caching'; | ||
import { ApolloServerPlugin } from 'apollo-server-plugin-base'; | ||
import { | ||
ApolloServerPlugin, | ||
GraphQLServiceContext, | ||
} from 'apollo-server-plugin-base'; | ||
import runtimeSupportsUploads from './utils/runtimeSupportsUploads'; | ||
|
||
import { | ||
|
@@ -558,19 +561,35 @@ export class ApolloServerBase { | |
|
||
protected async willStart() { | ||
const { schema, schemaHash } = await this.schemaDerivedData; | ||
const service: GraphQLServiceContext = { | ||
schema: schema, | ||
schemaHash: schemaHash, | ||
engine: { | ||
serviceID: this.engineServiceId, | ||
apiKeyHash: this.engineApiKeyHash, | ||
}, | ||
}; | ||
|
||
// The `persistedQueries` attribute on the GraphQLServiceContext was | ||
// originally used by the operation registry, which shared the cache with | ||
// it. This is no longer the case. However, while we are continuing to | ||
// expand the support of the interface for `persistedQueries`, e.g. with | ||
// additions like https://github.com/apollographql/apollo-server/pull/3623, | ||
// we don't want to continually expand the API surface of what we expose | ||
// to the plugin API. In this particular case, it certainly doesn't need | ||
// to get the `ttl` default value which are intended for APQ only. | ||
if (this.requestOptions.persistedQueries?.cache) { | ||
service.persistedQueries = { | ||
cache: this.requestOptions.persistedQueries.cache, | ||
} | ||
} | ||
|
||
persistedQueries: this.requestOptions.persistedQueries, | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
abernix
Author
Member
|
||
await Promise.all( | ||
this.plugins.map( | ||
plugin => | ||
plugin.serverWillStart && | ||
plugin.serverWillStart({ | ||
schema: schema, | ||
schemaHash: schemaHash, | ||
engine: { | ||
serviceID: this.engineServiceId, | ||
apiKeyHash: this.engineApiKeyHash, | ||
}, | ||
persistedQueries: this.requestOptions.persistedQueries, | ||
}), | ||
plugin.serverWillStart(service), | ||
), | ||
); | ||
} | ||
|
This looks like a copypasta error?