@envelop/execute-subscription-event 2.4.0-alpha-aca44e1.0 → 3.0.0-alpha-d0d0776.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 +1 -1
- package/index.js +3 -4
- package/index.mjs +3 -4
- package/package.json +19 -7
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ Utilities for hooking into the [ExecuteSubscriptionEvent](<https://spec.graphql.
|
|
|
4
4
|
|
|
5
5
|
### `useContextValuePerExecuteSubscriptionEvent`
|
|
6
6
|
|
|
7
|
-
Create a new context object per `ExecuteSubscriptionEvent` phase, allowing to bypass common issues with context objects such as [`DataLoader`](https://github.com/
|
|
7
|
+
Create a new context object per `ExecuteSubscriptionEvent` phase, allowing to bypass common issues with context objects such as [`DataLoader`](https://github.com/n1ru4l/envelop/issues/80) [caching](https://github.com/graphql/graphql-js/issues/894) [issues](https://github.com/apollographql/subscriptions-transport-ws/issues/330).
|
|
8
8
|
|
|
9
9
|
```ts
|
|
10
10
|
import { envelop } from '@envelop/core';
|
package/index.js
CHANGED
|
@@ -11,7 +11,7 @@ const core = require('@envelop/core');
|
|
|
11
11
|
*/
|
|
12
12
|
const subscribe = (execute) => core.makeSubscribe(async (args) => {
|
|
13
13
|
const { schema, document, rootValue, contextValue, variableValues, operationName, fieldResolver, subscribeFieldResolver } = args;
|
|
14
|
-
const resultOrStream = await graphql.createSourceEventStream(schema, document, rootValue, contextValue, variableValues
|
|
14
|
+
const resultOrStream = await graphql.createSourceEventStream(schema, document, rootValue, contextValue, variableValues ?? undefined, operationName, subscribeFieldResolver);
|
|
15
15
|
if (!core.isAsyncIterable(resultOrStream)) {
|
|
16
16
|
return resultOrStream;
|
|
17
17
|
}
|
|
@@ -38,7 +38,6 @@ const useExtendContextValuePerExecuteSubscriptionEvent = (createContext) => {
|
|
|
38
38
|
return {
|
|
39
39
|
onSubscribe({ args, setSubscribeFn }) {
|
|
40
40
|
const executeNew = core.makeExecute(async (executionArgs) => {
|
|
41
|
-
var _a;
|
|
42
41
|
const context = await createContext({ args });
|
|
43
42
|
try {
|
|
44
43
|
return await graphql.execute({
|
|
@@ -46,11 +45,11 @@ const useExtendContextValuePerExecuteSubscriptionEvent = (createContext) => {
|
|
|
46
45
|
// GraphQL.js 16 changed the type of contextValue to unknown
|
|
47
46
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
48
47
|
// @ts-ignore
|
|
49
|
-
contextValue: { ...executionArgs.contextValue, ...context
|
|
48
|
+
contextValue: { ...executionArgs.contextValue, ...context?.contextPartial },
|
|
50
49
|
});
|
|
51
50
|
}
|
|
52
51
|
finally {
|
|
53
|
-
|
|
52
|
+
context?.onEnd?.();
|
|
54
53
|
}
|
|
55
54
|
});
|
|
56
55
|
setSubscribeFn(subscribe(executeNew));
|
package/index.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import { makeSubscribe, isAsyncIterable, mapAsyncIterator, makeExecute } from '@
|
|
|
7
7
|
*/
|
|
8
8
|
const subscribe = (execute) => makeSubscribe(async (args) => {
|
|
9
9
|
const { schema, document, rootValue, contextValue, variableValues, operationName, fieldResolver, subscribeFieldResolver } = args;
|
|
10
|
-
const resultOrStream = await createSourceEventStream(schema, document, rootValue, contextValue, variableValues
|
|
10
|
+
const resultOrStream = await createSourceEventStream(schema, document, rootValue, contextValue, variableValues ?? undefined, operationName, subscribeFieldResolver);
|
|
11
11
|
if (!isAsyncIterable(resultOrStream)) {
|
|
12
12
|
return resultOrStream;
|
|
13
13
|
}
|
|
@@ -34,7 +34,6 @@ const useExtendContextValuePerExecuteSubscriptionEvent = (createContext) => {
|
|
|
34
34
|
return {
|
|
35
35
|
onSubscribe({ args, setSubscribeFn }) {
|
|
36
36
|
const executeNew = makeExecute(async (executionArgs) => {
|
|
37
|
-
var _a;
|
|
38
37
|
const context = await createContext({ args });
|
|
39
38
|
try {
|
|
40
39
|
return await execute({
|
|
@@ -42,11 +41,11 @@ const useExtendContextValuePerExecuteSubscriptionEvent = (createContext) => {
|
|
|
42
41
|
// GraphQL.js 16 changed the type of contextValue to unknown
|
|
43
42
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
44
43
|
// @ts-ignore
|
|
45
|
-
contextValue: { ...executionArgs.contextValue, ...context
|
|
44
|
+
contextValue: { ...executionArgs.contextValue, ...context?.contextPartial },
|
|
46
45
|
});
|
|
47
46
|
}
|
|
48
47
|
finally {
|
|
49
|
-
|
|
48
|
+
context?.onEnd?.();
|
|
50
49
|
}
|
|
51
50
|
});
|
|
52
51
|
setSubscribeFn(subscribe(executeNew));
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@envelop/execute-subscription-event",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-alpha-d0d0776.0",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"peerDependencies": {
|
|
6
|
-
"@envelop/core": "
|
|
6
|
+
"@envelop/core": "3.0.0-alpha-d0d0776.0",
|
|
7
7
|
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
|
|
8
8
|
},
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
|
-
"url": "https://github.com/
|
|
11
|
+
"url": "https://github.com/n1ru4l/envelop.git",
|
|
12
12
|
"directory": "packages/plugins/execute-subscription-event"
|
|
13
13
|
},
|
|
14
14
|
"author": "Laurin Quast <laurinquast@googlemail.com>",
|
|
@@ -21,12 +21,24 @@
|
|
|
21
21
|
},
|
|
22
22
|
"exports": {
|
|
23
23
|
".": {
|
|
24
|
-
"require":
|
|
25
|
-
|
|
24
|
+
"require": {
|
|
25
|
+
"default": "./index.js",
|
|
26
|
+
"types": "./index.d.ts"
|
|
27
|
+
},
|
|
28
|
+
"import": {
|
|
29
|
+
"default": "./index.mjs",
|
|
30
|
+
"types": "./index.d.ts"
|
|
31
|
+
}
|
|
26
32
|
},
|
|
27
33
|
"./*": {
|
|
28
|
-
"require":
|
|
29
|
-
|
|
34
|
+
"require": {
|
|
35
|
+
"default": "./*.js",
|
|
36
|
+
"types": "./*.d.ts"
|
|
37
|
+
},
|
|
38
|
+
"import": {
|
|
39
|
+
"default": "./*.mjs",
|
|
40
|
+
"types": "./*.d.ts"
|
|
41
|
+
}
|
|
30
42
|
},
|
|
31
43
|
"./package.json": "./package.json"
|
|
32
44
|
}
|