@envelop/graphql-jit 4.3.0-alpha-26c4ae2.0 → 4.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +80 -0
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
## `@envelop/graphql-jit`
|
|
2
|
+
|
|
3
|
+
This plugins replaces the original `execute` of GraphQL with [`graphql-jit`](https://github.com/zalando-incubator/graphql-jit).
|
|
4
|
+
|
|
5
|
+
## Getting Started
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
yarn add @envelop/graphql-jit
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage Example
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { envelop } from '@envelop/core';
|
|
15
|
+
import { useGraphQlJit } from '@envelop/graphql-jit';
|
|
16
|
+
|
|
17
|
+
const getEnveloped = envelop({
|
|
18
|
+
plugins: [
|
|
19
|
+
// ... other plugins ...
|
|
20
|
+
useGraphQlJit(
|
|
21
|
+
{
|
|
22
|
+
// your compiler options here. See https://github.com/zalando-incubator/graphql-jit#compiledquery--compilequeryschema-document-operationname-compileroptions
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
onError: (e: Error) => { ... } // custom error handler
|
|
26
|
+
}
|
|
27
|
+
),
|
|
28
|
+
],
|
|
29
|
+
});
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Conditional Execution
|
|
33
|
+
|
|
34
|
+
If you wish to conditionally use the JIT executor based on the incoming request, you can use `enableIf` config flag and return a `boolean` based on the `ExecutionArgs`:
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
import { envelop } from '@envelop/core';
|
|
38
|
+
import { useGraphQlJit } from '@envelop/graphql-jit';
|
|
39
|
+
|
|
40
|
+
const getEnveloped = envelop({
|
|
41
|
+
plugins: [
|
|
42
|
+
// ... other plugins ...
|
|
43
|
+
useGraphQlJit(
|
|
44
|
+
{
|
|
45
|
+
// your compiler options here. See https://github.com/zalando-incubator/graphql-jit#compiledquery--compilequeryschema-document-operationname-compileroptions
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
enableIf: executionArgs => executionArgs.contextValue.shouldUseJit,
|
|
49
|
+
}
|
|
50
|
+
),
|
|
51
|
+
],
|
|
52
|
+
});
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Configuring JIT cache
|
|
56
|
+
|
|
57
|
+
You can configure the JIT cache with the following options:
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
import { envelop } from '@envelop/core';
|
|
61
|
+
import { useGraphQlJit } from '@envelop/graphql-jit';
|
|
62
|
+
|
|
63
|
+
const getEnveloped = envelop({
|
|
64
|
+
plugins: [
|
|
65
|
+
// ... other plugins ...
|
|
66
|
+
useGraphQlJit(
|
|
67
|
+
{
|
|
68
|
+
// your compiler options here
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
cache: lru(), // Pass in a custom cache instance, by default a new LRU cache is created which uses the default `max` and `ttl` settings
|
|
72
|
+
}
|
|
73
|
+
),
|
|
74
|
+
],
|
|
75
|
+
});
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Notes
|
|
79
|
+
|
|
80
|
+
You can find more details here: https://github.com/zalando-incubator/graphql-jit
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@envelop/graphql-jit",
|
|
3
|
-
"version": "4.3.0
|
|
3
|
+
"version": "4.3.0",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"peerDependencies": {
|
|
6
|
-
"@envelop/core": "2.4.0
|
|
6
|
+
"@envelop/core": "^2.4.0",
|
|
7
7
|
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|