@envelop/response-cache
9.1.1
Patch Changes
- Updated dependencies
[
0bfde27]:- @envelop/core@5.5.1
9.1.0
Patch Changes
- #2827
dc2327dThanks @renovate ! - dependencies updates:- Updated dependency
@graphql-tools/utils@^11.0.0↗︎ (from^10.0.3, independencies)
- Updated dependency
- Updated dependencies
[
d3d83bc]:- @envelop/core@5.5.0
9.0.0
Patch Changes
- Updated dependencies
[
0434fbd]:- @envelop/core@5.4.0
8.1.0
Minor Changes
-
#2258
35539a7Thanks @EmrysMyrddin ! - DeprecatettlPerTypein favor ofttlPerSchemaCoordinate, for a more streamlined APIMigration instructions
If you where using
ttlPerType, you can merge the object into thettlPerSchemaCoordinate, the syntax doesn’t change.useResponseCache({ session: null, - ttlPerType: { - User: 10_000, - Profile: 600_000, - }, ttlPerSchemaCoordinate: { 'Query.me': 0 + User: 10_000, + Profile: 600_000, } })
8.0.2
Patch Changes
- #2262
2525301Thanks @renovate ! - dependencies updates:- Updated dependency
lru-cache@^11.0.0↗︎ (from^10.0.0, independencies)
- Updated dependency
- Updated dependencies
[
92948d8]:- @envelop/core@5.3.2
8.0.1
Patch Changes
-
#2611
8dd5bdaThanks @EmrysMyrddin ! - Add awithStateoverride to ease the typing of plugins whith the same state for all scopes. -
Updated dependencies [
8dd5bda]:- @envelop/core@5.3.1
8.0.0
Patch Changes
- Updated dependencies
[
3ebaa3b]:- @envelop/core@5.3.0
7.1.3
Patch Changes
7.1.2
Patch Changes
-
#2484
26137e7Thanks @renovate ! - dependencies updates:- Added dependency
@whatwg-node/promise-helpers@^1.2.4↗︎ (todependencies)
- Added dependency
-
#2484
26137e7Thanks @renovate ! - dependencies updates:- Added dependency
@whatwg-node/promise-helpers@^1.2.4↗︎ (todependencies)
- Added dependency
-
Updated dependencies [
26137e7,26137e7]:- @envelop/core@5.2.2
7.1.1
Patch Changes
7.1.0
Patch Changes
7.0.1
Patch Changes
- Updated dependencies
[
5b6a166]:- @envelop/core@5.1.1
7.0.0
Patch Changes
-
#2438
9bd1b20Thanks @ardatan ! - Handle instance objects properly (JS Date etc) -
Updated dependencies [
9bd1b20]:- @envelop/core@5.1.0
6.3.0
Minor Changes
6.2.5
Patch Changes
- #2337
931a6daThanks @renovate ! - dependencies updates:- Updated dependency
@whatwg-node/fetch@^0.10.0↗︎ (from^0.9.0, independencies)
- Updated dependency
6.2.4
Patch Changes
c1720a8Thanks @n1ru4l ! - Fix handling of primitive list values that was introduced in the last release.
6.2.3
Patch Changes
6.2.2
Patch Changes
- #2309
4fd5917Thanks @n1ru4l ! - Strip__responseCacheIdand__responseCacheTypeNamefrom incremental delivery execution result.
6.2.1
Patch Changes
- #2266
389d5f6Thanks @EmrysMyrddin ! - The plugin now try to reduce the size of the resulting query by not adding a__typenamealiased selection if__typenameis already selected.
6.2.0
Minor Changes
- #2238
430ee7dThanks @ardatan ! - Accept a factory function tocachethat takes the context and returns the cache implementation
6.1.2
Patch Changes
4a1e50bThanks @EmrysMyrddin ! - Do not cache response with a TTL equal to 0, whatever API is used to define the TTL
6.1.1
Patch Changes
- #2094
cafc43fThanks @EmrysMyrddin ! - Run enabled once only in execution
- #2090
09a4bc1Thanks @klippx ! - Fix TTL being NaN when using@cacheControlwithoutmaxAgeargument.
6.1.0
Minor Changes
- #2044
5d87e987Thanks @EmrysMyrddin ! - ExposehashSHA256sha256 implementation to ease the customization of cache key factory.
6.0.1
Patch Changes
4183b275Thanks @EmrysMyrddin ! - Fix leak of cache metadata in the result when cache is skipped.
6.0.0
Major Changes
- #1986
68e7a2a5Thanks @EmrysMyrddin ! - Breaking Change: Support of Node 16 is dropped.
-
#1977
a4343beeThanks @EmrysMyrddin ! - Theenableparameter now allows to entirely disable caching. It is checked eagerly and disables all cache related processing.Breaking Change:
Previously,
enablewas only controlling cache reading. This means that previously, the automatic cache invalidation was still working even withenablereturning false, which is no longer the case. The alternative is to cautiously invalidate data in the related resolvers. -
Updated dependencies [
68e7a2a5,f7ef03c0]:- @envelop/core@5.0.0
5.5.0
Minor Changes
- #1970
b2ce17e2Thanks @EmrysMyrddin ! - Automatically add the entities id to the request document. This change allows the plugin to not require anymore each query to carefuly include all keys of all entities.
5.4.0
Minor Changes
5.3.2
Patch Changes
- #1927
e3c90116Thanks @renovate ! - dependencies updates:- Updated dependency
@envelop/core@^4.0.2↗︎ (from^4.0.1, inpeerDependencies)
- Updated dependency
-
c9e493b8Thanks @ardatan ! - Ignore subscriptions in response caching -
Updated dependencies [
dee6b8d2]:- @envelop/core@4.0.3
5.3.1
Patch Changes
-
#1956
d427c338Thanks @ardatan ! - Do not add __typename in the root of subscription operations -
#1955
83b77b60Thanks @EmrysMyrddin ! - Handle mutations when using@deferor@streamdirectives -
Updated dependencies [
db20864a]:- @envelop/core@4.0.2
5.3.0
Minor Changes
- #1941
be16ad2cThanks @EmrysMyrddin ! - Give access to the context in the cache key builder function
5.2.0
Minor Changes
-
#1884
58174743Thanks @EmrysMyrddin ! - add support for scopes to enforce cache privacy -
#1896
834e1e39Thanks @EmrysMyrddin ! - add support for @defer and @stream
Patch Changes
-
#1896
834e1e39Thanks @EmrysMyrddin ! - dependencies updates:- Updated dependency
@graphql-tools/utils@^10.0.3↗︎ (from^10.0.0, independencies)
- Updated dependency
-
Updated dependencies []:
- @envelop/core@4.0.1
5.1.0
Minor Changes
- #1603
ea907c60Thanks @ardatan ! - Support fordirective @cacheControl(maxAge: Int) on FIELD_DEFINITION | OBJECT | INTERFACE | UNION
Patch Changes
-
#1879
d3ecee35Thanks @renovate ! - dependencies updates:- Updated dependency
lru-cache@^10.0.0↗︎ (from^9.1.1, independencies)
- Updated dependency
-
#1883
84eb5b46Thanks @EmrysMyrddin ! - fix response cache extensions type
5.0.1
Patch Changes
- #1873
914d78c3Thanks @ardatan ! - Do not revisit cached parser result which adds extra __typename properties in the execution result
5.0.0
Major Changes
-
#1776
332f1f22Thanks @ardatan ! - Drop Node 14 and require Node 16 or higher -
#1767
0b127cc4Thanks @n1ru4l ! - bump lru cache dependency version -
Updated dependencies [
332f1f22,a36925c7]:- @envelop/core@4.0.0
Patch Changes
-
#1767
0b127cc4Thanks @n1ru4l ! - dependencies updates:- Updated dependency
lru-cache@^9.1.1↗︎ (from^6.0.0, independencies)
- Updated dependency
-
#1776
332f1f22Thanks @ardatan ! - dependencies updates:- Updated dependency
@graphql-tools/utils@^10.0.0↗︎ (from^8.8.0, independencies) - Updated dependency
@whatwg-node/fetch@^0.9.0↗︎ (from^0.8.0, independencies)
- Updated dependency
-
#1728
a36925c7Thanks @ardatan ! - - Memoize parsed document string result and use it wherever possible, and exportgetDocumentStringfunction to allow users to use it as well.- Use
WeakMaps withDocumentNodewherever possible instead of using LRU Cache with strings. It is more optimal if a parser caching is used
- Use
4.0.8
Patch Changes
- #1735
972c087fThanks @renovate ! - dependencies updates:- Updated dependency
@whatwg-node/fetch@^0.8.0↗︎ (from^0.6.5, independencies)
- Updated dependency
4.0.7
Patch Changes
-
#1725
c1eb2c09Thanks @n1ru4l ! - dependencies updates:- Updated dependency
tslib@^2.5.0↗︎ (from^2.4.0, independencies)
- Updated dependency
-
Updated dependencies [
c1eb2c09]:- @envelop/core@3.0.6
4.0.6
Patch Changes
- #1724
94e39a5dThanks @ardatan ! - - Respect existing extensions in the result- Add
cacheKeytoshouldCacheResultfunction
- Add
- Updated dependencies
[
270249cf]:- @envelop/core@3.0.5
4.0.5
Patch Changes
-
#1623
d50fa6f0Thanks @ardatan ! - dependencies updates:- Added dependency
@whatwg-node/fetch@^0.6.5↗︎ (todependencies)
- Added dependency
-
#1625
8a90f541Thanks @mayrn-techdivision ! - Fix ignoredTypes and ttlPerType not working for types without id field
4.0.4
Patch Changes
- Updated dependencies []:
- @envelop/core@3.0.4
4.0.3
Patch Changes
- Updated dependencies
[
6b48ef96]:- @envelop/core@3.0.3
4.0.2
Patch Changes
-
#1560
22f5ccfbThanks @enisdenjo ! - Plugins with context generic for correct inheritance -
Updated dependencies [
22f5ccfb]:- @envelop/core@3.0.2
4.0.0
Major Changes
- Updated dependencies
[
dc1e24b5,dc1e24b5,dc1e24b5,dc1e24b5,dc1e24b5,dc1e24b5,dc1e24b5,dc1e24b5,dc1e24b5,dc1e24b5,dc1e24b5,dc1e24b5,dc1e24b5,dc1e24b5]:- @envelop/core@3.0.0
3.2.0
Minor Changes
-
#1499
1f7af02bThanks @viniciuspalma ! - Adding tslib to package dependenciesProjects that currently are using yarn Berry with PnP or any strict dependency resolver, that requires that all dependencies are specified on package.json otherwise it would endue in an error if not treated correct
Since https://www.typescriptlang.org/tsconfig#importHelpers is currently being used, tslib should be exported as a dependency to external runners get the proper import.
Change on each package:
// package.json { "dependencies": { "tslib": "^2.4.0" } } -
Updated dependencies [
1f7af02b,ae7bc9a3]:- @envelop/core@2.6.0
3.1.0
Minor Changes
3.0.2
Patch Changes
- 071f946: Fix CommonJS TypeScript resolution with
moduleResolutionnode16ornodenext - Updated dependencies [071f946]
- @envelop/core@2.4.2
3.0.1
Patch Changes
- Updated dependencies [787d28a2]
- @envelop/core@2.4.1
3.0.0
Major Changes
-
887fc07: BREAKING Require the user to provide a
sessionfunction by default.Previously, using the response cache automatically used a global cache. For security reasons there is no longer a default value for the
sessionconfig property. If you did not set thesessionfunction before and want a global cache that is shared by all users, you need to update your code to the following:import { envelop } from '@envelop/core' import { useResponseCache } from '@envelop/response-cache' const getEnveloped = envelop({ plugins: [ // ... other plugins ... useResponseCache({ // use global cache for all operations session: () => null }) ] })Otherwise, you should return from your cache function a value that uniquely identifies the viewer.
import { envelop } from '@envelop/core' import { useResponseCache } from '@envelop/response-cache' const getEnveloped = envelop({ plugins: [ // ... other plugins ... useResponseCache({ // return null as a fallback for caching the result globally session: context => context.user?.id ?? null }) ] }) -
a5d8dcb: Better default document string storage
Previously non parsed operation document was stored in the context with a symbol to be used “documentString” in the later. But this can be solved with a “WeakMap” so the modification in the context is no longer needed.
BREAKING CHANGE: Replace
getDocumentStringFromContextwithgetDocumentStringHowever, some users might provide document directly to the execution without parsing it via
parse. So in that case, we replaced the context parameter with the execution args includingdocument,variableValuesandcontextValueto the newgetDocumentString.Now a valid document string should be returned from the new
getDocumentString.Custom document string caching example.
const myCache = new WeakMap<DocumentNode, string>() // Let's say you keep parse results in somewhere else like below function parseDocument(document: string): DocumentNode { const parsedDocument = parse(document) myCache.set(parsedDocument, document) return parsedDocument } // Then you can interact with your existing caching solution inside the response cache plugin like below useResponseCache({ getDocumentString(document: DocumentNode): string { // You can also add a fallback to `graphql-js`'s print function // to let the plugin works const possibleDocumentStr = myCache.get(document) if (!possibleDocumentStr) { console.warn(`Something might be wrong with my cache setup`) return print(document) } return possibleDocumentStr } })Migration from
getDocumentStringFromContext.So if you use
getDocumentStringFromContextlike below before;function getDocumentStringFromContext(contextValue: any) { return contextValue.myDocumentString }You have to change it to the following;
import { print } from 'graphql' function getDocumentString(executionArgs: ExecutionArgs) { // We need to fallback to `graphql`'s print to return a value no matter what. return executionArgs.contextValue.myDocumentString ?? print(executionArgs.document) }
2.4.0
Minor Changes
- 8bb2738: Support TypeScript module resolution.
- Updated dependencies [8bb2738]
- @envelop/core@2.4.0
2.3.3
Patch Changes
- fbf6155: update package.json repository links to point to the new home
- Updated dependencies [fbf6155]
- @envelop/core@2.3.3
2.3.2
Patch Changes
- Updated dependencies [07d029b]
- @envelop/core@2.3.2
2.3.1
Patch Changes
- Updated dependencies [d5c2c9a]
- @envelop/core@2.3.1
2.3.0
Minor Changes
- Updated dependencies [af23408]
- @envelop/core@2.3.0
2.2.0
Minor Changes
- Updated dependencies [ada7fb0]
- Updated dependencies [d5115b4]
- Updated dependencies [d5115b4]
- @envelop/core@2.2.0
2.1.1
Patch Changes
- 5400c3f: fix infinite loop while applying schema transforms
2.1.0
Minor Changes
- Updated dependencies [78b3db2]
- Updated dependencies [f5eb436]
- @envelop/core@2.1.0
2.0.0
Patch Changes
- Updated dependencies [4106e08]
- Updated dependencies [aac65ef]
- Updated dependencies [4106e08]
- @envelop/core@2.0.0
1.0.1
Patch Changes
- 3dfddb5: Bump graphql-tools/utils to v8.6.1 to address a bug in getArgumentsValues
- Updated dependencies [3dfddb5]
- @envelop/core@1.7.1
1.0.0
Patch Changes
- Updated dependencies [d9cfb7c]
- @envelop/core@1.7.0
0.6.0
Minor Changes
-
b919b21: Add cross-platform support for platforms that do not have the
Node.jscryptomodule available by using theWebCryptoAPI. This adds support for deno, cloudflare workers and the browser.BREAKING: The
BuildResponseCacheKeyFunctionfunction type now returnsPromise<string>instead ofstring.. The functiondefaultBuildResponseCacheKeynow returns aPromise. TheUseResponseCacheParameter.buildResponseCacheKeyconfig option must return aPromise. BREAKING: ThedefaultBuildResponseCacheKeynow uses the hash algorithmSHA256instead ofSHA1.
0.5.1
Patch Changes
-
b1a0331: Properly list
@envelop/coreas apeerDependencyin plugins.This resolves issues where the bundled envelop plugins published to npm had logic inlined from the
@envelop/corepackage, causinginstanceofcheck ofEnvelopErrorto fail. -
Updated dependencies [b1a0331]
- @envelop/core@1.6.1
0.5.0
Minor Changes
- 090cae4: GraphQL v16 support
0.4.0
Minor Changes
- 04120de: add support for GraphQL.js 16
0.3.0
Minor Changes
-
0623cf7: Introspection query operations are no longer cached by default.
In case you still want to cache query operations you can set the
ttlPerSchemaCoordinateparameter to{ "Query.__schema": undefined }for caching introspection forever or{ "Query.__schema": 100 }for caching introspection for a specific time. We do not recommend caching introspection.Query operation execution results that contain errors are no longer cached.
0.2.1
Patch Changes
-
9688945: Allow to set ttl=0 to disable caching, and use ttlPerType to maintain a whitelist
-
a749ec0: Include operationName for building the cache key hash. Previously, sending the same operation document with a different operationName value could result in the wrong response being served from the cache.
Use
fast-json-stable-stringifyfor stringifying the variableValues. This will ensure that the cache is hit more often as the variable value serialization is now more stable.
0.2.0
Minor Changes
-
075fc77: Expose metadata by setting the
includeExtensionMetadataoption.extension.responseCache.hit- Whether the result was served form the cache or notextension.responseCache.invalidatedEntities- Entities that got invalidated by a mutation operation
Take a look at the README for mor information and examples.
0.1.0
Minor Changes
- 823b335: initial release