Skip to content

Commit 528c9cd

Browse files
authored
Merge pull request #152 from thematters/develop
release: 2.0.0-alpha.0
2 parents 431fac5 + 8143736 commit 528c9cd

File tree

9 files changed

+6003
-3281
lines changed

9 files changed

+6003
-3281
lines changed

.github/dependabot.yml

Lines changed: 0 additions & 19 deletions
This file was deleted.

README.md

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ Once a mutation updates this node, `@purgeCache` will purge related `fqc`.
2020

2121
### Usage
2222

23+
*Note: there are breaking changes in API from 1.4.0 to 2.0.0, see below Breaking changes section for more info*
24+
25+
2326
Install package:
2427

2528
```bash
@@ -30,35 +33,27 @@ Add plugin and directives to the constructor:
3033

3134
```ts
3235
import {
36+
logCacheDirective,
37+
purgeCacheDirective,
3338
responseCachePlugin,
34-
LogCacheDirective,
35-
PurgeCacheDirective,
3639
} from '@matters/apollo-response-cache'
3740

38-
const server = new ApolloServer({
39-
plugins: [responseCachePlugin()],
40-
})
41+
const {typeDef: logCacheDirectiveTypeDef, transformer: logCacheDirectiveTransformer} = logCacheDirective()
42+
const {typeDef: purgeCacheDirectiveTypeDef, transformer: purgeCacheDirectiveTransformer} = purgeCacheDirective()
4143

42-
const schema = makeExecutableSchema({
43-
schemaDirectives: {
44-
logCache: LogCacheDirective(),
45-
purgeCache: PurgeCacheDirective(),
46-
},
44+
let schema = makeExecutableSchema({
45+
typeDefs: [yourTypeDef, logCacheDirectiveTypeDef, purgeCacheDirectiveTypeDef]
4746
})
48-
```
4947

50-
Add definitions to your schema:
48+
schema = logCacheDirectiveTransformer(
49+
purgeCacheDirectiveTransformer(schema)
50+
)
51+
52+
const server = new ApolloServer({
53+
schema,
54+
plugins: [responseCachePlugin()],
55+
})
5156

52-
```graphql
53-
directive @logCache(
54-
type: String!
55-
identifier: String = "id"
56-
) on FIELD_DEFINITION
57-
58-
directive @purgeCache(
59-
type: String!
60-
identifier: String = "id"
61-
) on FIELD_DEFINITION
6257
```
6358

6459
Use in the schema:
@@ -128,6 +123,19 @@ const schema = makeExecutableSchema({
128123
})
129124
```
130125

126+
### Breaking changes in 2.0.0
127+
128+
1. Support apollo-server v4 now, but drop support for apollo-server v3 and graphql-tools v8 and below
129+
2. All APIs, including plugin option, directives, helpers interface, changed:
130+
a. pulgin constructor take redis client (type `Redis` from ioredis) instead of `RedisCache` from deprecated apollo-server-cache-redis
131+
b. invalidateFQC take redis instead of `RedisCache`
132+
c. directives api is totally changed to function way, as graphql-tools/utils v8 depreacated class base SchemaDirectiveVisitor
133+
134+
### Known issues
135+
136+
If hit `Types have separate declarations of a private property '__identity'` when build apollo server codebase, make sure both direct dependency on `@apollo/server` and this package dependency on `@apollo/server` share totally same version.
137+
138+
131139
### TODOs
132140

133141
- [x] responseCachePlugin

0 commit comments

Comments
 (0)