@envelop/execute-subscription-event 2.4.0 → 2.4.1-alpha-72027859.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 CHANGED
@@ -7,35 +7,35 @@ Utilities for hooking into the [ExecuteSubscriptionEvent](<https://spec.graphql.
7
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
- import { envelop } from '@envelop/core';
11
- import { useContextValuePerExecuteSubscriptionEvent } from '@envelop/execute-subscription-event';
12
- import { createContext, createDataLoaders } from './context';
10
+ import { envelop } from '@envelop/core'
11
+ import { useContextValuePerExecuteSubscriptionEvent } from '@envelop/execute-subscription-event'
12
+ import { createContext, createDataLoaders } from './context'
13
13
 
14
14
  const getEnveloped = envelop({
15
15
  plugins: [
16
- useContext(() => createContext())
16
+ useContext(() => createContext()),
17
17
  useContextValuePerExecuteSubscriptionEvent(() => ({
18
18
  // Existing context is merged with this context partial
19
19
  // By recreating the DataLoader we ensure no DataLoader caches from the previous event/initial field subscribe call are are hit
20
20
  contextPartial: {
21
21
  dataLoaders: createDataLoaders()
22
- },
23
- })),
22
+ }
23
+ }))
24
24
  // ... other plugins ...
25
- ],
26
- });
25
+ ]
26
+ })
27
27
  ```
28
28
 
29
29
  Alternatively, you can also provide a callback that is invoked after each [`ExecuteSubscriptionEvent`](<https://spec.graphql.org/draft/#ExecuteSubscriptionEvent()>) phase.
30
30
 
31
31
  ```ts
32
- import { envelop } from '@envelop/core';
33
- import { useContextValuePerExecuteSubscriptionEvent } from '@envelop/execute-subscription-event';
34
- import { createContext, createDataLoaders } from './context';
32
+ import { envelop } from '@envelop/core'
33
+ import { useContextValuePerExecuteSubscriptionEvent } from '@envelop/execute-subscription-event'
34
+ import { createContext, createDataLoaders } from './context'
35
35
 
36
36
  const getEnveloped = envelop({
37
37
  plugins: [
38
- useContext(() => createContext())
38
+ useContext(() => createContext()),
39
39
  useContextValuePerExecuteSubscriptionEvent(({ args }) => ({
40
40
  onEnd: () => {
41
41
  // Note that onEnd is invoked only after each ExecuteSubscriptionEvent phase
@@ -44,8 +44,8 @@ const getEnveloped = envelop({
44
44
  args.contextValue.dataLoaders.users.clearAll()
45
45
  args.contextValue.dataLoaders.posts.clearAll()
46
46
  }
47
- })),
47
+ }))
48
48
  // ... other plugins ...
49
- ],
50
- });
49
+ ]
50
+ })
51
51
  ```
package/cjs/subscribe.js CHANGED
@@ -8,7 +8,7 @@ const core_1 = require("@envelop/core");
8
8
  * The only difference is that a custom `execute` function can be injected for customizing the behavior.
9
9
  */
10
10
  const subscribe = (execute) => (0, core_1.makeSubscribe)(async (args) => {
11
- const { schema, document, rootValue, contextValue, variableValues, operationName, fieldResolver, subscribeFieldResolver } = args;
11
+ const { schema, document, rootValue, contextValue, variableValues, operationName, fieldResolver, subscribeFieldResolver, } = args;
12
12
  const resultOrStream = await (0, graphql_1.createSourceEventStream)(schema, document, rootValue, contextValue, variableValues !== null && variableValues !== void 0 ? variableValues : undefined, operationName, subscribeFieldResolver);
13
13
  if (!(0, core_1.isAsyncIterable)(resultOrStream)) {
14
14
  return resultOrStream;
package/esm/subscribe.js CHANGED
@@ -5,7 +5,7 @@ import { makeSubscribe, mapAsyncIterator, isAsyncIterable } from '@envelop/core'
5
5
  * The only difference is that a custom `execute` function can be injected for customizing the behavior.
6
6
  */
7
7
  export const subscribe = (execute) => makeSubscribe(async (args) => {
8
- const { schema, document, rootValue, contextValue, variableValues, operationName, fieldResolver, subscribeFieldResolver } = args;
8
+ const { schema, document, rootValue, contextValue, variableValues, operationName, fieldResolver, subscribeFieldResolver, } = args;
9
9
  const resultOrStream = await createSourceEventStream(schema, document, rootValue, contextValue, variableValues !== null && variableValues !== void 0 ? variableValues : undefined, operationName, subscribeFieldResolver);
10
10
  if (!isAsyncIterable(resultOrStream)) {
11
11
  return resultOrStream;
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@envelop/execute-subscription-event",
3
- "version": "2.4.0",
3
+ "version": "2.4.1-alpha-72027859.0",
4
4
  "sideEffects": false,
5
5
  "peerDependencies": {
6
- "@envelop/core": "^2.4.0",
6
+ "@envelop/core": "2.4.1-alpha-72027859.0",
7
7
  "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
8
8
  },
9
9
  "dependencies": {},