@envelop/execute-subscription-event 2.6.0 → 2.6.1-alpha-20220901205925-b1fd44a9

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,11 +7,16 @@ 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 { parse, validate, execute, subscribe } from 'graphql'
10
11
  import { envelop } from '@envelop/core'
11
12
  import { useContextValuePerExecuteSubscriptionEvent } from '@envelop/execute-subscription-event'
12
13
  import { createContext, createDataLoaders } from './context'
13
14
 
14
15
  const getEnveloped = envelop({
16
+ parse,
17
+ validate,
18
+ execute,
19
+ subscribe,
15
20
  plugins: [
16
21
  useContext(() => createContext()),
17
22
  useContextValuePerExecuteSubscriptionEvent(() => ({
package/cjs/index.js CHANGED
@@ -8,7 +8,6 @@ const useExtendContextValuePerExecuteSubscriptionEvent = (createContext) => {
8
8
  return {
9
9
  onSubscribe({ args, setSubscribeFn }) {
10
10
  const executeNew = (0, core_1.makeExecute)(async (executionArgs) => {
11
- var _a;
12
11
  const context = await createContext({ args });
13
12
  try {
14
13
  return await (0, graphql_1.execute)({
@@ -16,11 +15,11 @@ const useExtendContextValuePerExecuteSubscriptionEvent = (createContext) => {
16
15
  // GraphQL.js 16 changed the type of contextValue to unknown
17
16
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
18
17
  // @ts-ignore
19
- contextValue: { ...executionArgs.contextValue, ...context === null || context === void 0 ? void 0 : context.contextPartial },
18
+ contextValue: { ...executionArgs.contextValue, ...context?.contextPartial },
20
19
  });
21
20
  }
22
21
  finally {
23
- (_a = context === null || context === void 0 ? void 0 : context.onEnd) === null || _a === void 0 ? void 0 : _a.call(context);
22
+ context?.onEnd?.();
24
23
  }
25
24
  });
26
25
  setSubscribeFn((0, subscribe_js_1.subscribe)(executeNew));
package/cjs/subscribe.js CHANGED
@@ -9,7 +9,7 @@ const core_1 = require("@envelop/core");
9
9
  */
10
10
  const subscribe = (execute) => (0, core_1.makeSubscribe)(async (args) => {
11
11
  const { schema, document, rootValue, contextValue, variableValues, operationName, fieldResolver, subscribeFieldResolver, } = args;
12
- const resultOrStream = await (0, graphql_1.createSourceEventStream)(schema, document, rootValue, contextValue, variableValues !== null && variableValues !== void 0 ? variableValues : undefined, operationName, subscribeFieldResolver);
12
+ const resultOrStream = await (0, graphql_1.createSourceEventStream)(schema, document, rootValue, contextValue, variableValues ?? undefined, operationName, subscribeFieldResolver);
13
13
  if (!(0, core_1.isAsyncIterable)(resultOrStream)) {
14
14
  return resultOrStream;
15
15
  }
package/esm/index.js CHANGED
@@ -5,7 +5,6 @@ export const useExtendContextValuePerExecuteSubscriptionEvent = (createContext)
5
5
  return {
6
6
  onSubscribe({ args, setSubscribeFn }) {
7
7
  const executeNew = makeExecute(async (executionArgs) => {
8
- var _a;
9
8
  const context = await createContext({ args });
10
9
  try {
11
10
  return await execute({
@@ -13,11 +12,11 @@ export const useExtendContextValuePerExecuteSubscriptionEvent = (createContext)
13
12
  // GraphQL.js 16 changed the type of contextValue to unknown
14
13
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
15
14
  // @ts-ignore
16
- contextValue: { ...executionArgs.contextValue, ...context === null || context === void 0 ? void 0 : context.contextPartial },
15
+ contextValue: { ...executionArgs.contextValue, ...context?.contextPartial },
17
16
  });
18
17
  }
19
18
  finally {
20
- (_a = context === null || context === void 0 ? void 0 : context.onEnd) === null || _a === void 0 ? void 0 : _a.call(context);
19
+ context?.onEnd?.();
21
20
  }
22
21
  });
23
22
  setSubscribeFn(subscribe(executeNew));
package/esm/subscribe.js CHANGED
@@ -6,7 +6,7 @@ import { makeSubscribe, mapAsyncIterator, isAsyncIterable } from '@envelop/core'
6
6
  */
7
7
  export const subscribe = (execute) => makeSubscribe(async (args) => {
8
8
  const { schema, document, rootValue, contextValue, variableValues, operationName, fieldResolver, subscribeFieldResolver, } = args;
9
- const resultOrStream = await createSourceEventStream(schema, document, rootValue, contextValue, variableValues !== null && variableValues !== void 0 ? variableValues : undefined, operationName, subscribeFieldResolver);
9
+ const resultOrStream = await createSourceEventStream(schema, document, rootValue, contextValue, variableValues ?? undefined, operationName, subscribeFieldResolver);
10
10
  if (!isAsyncIterable(resultOrStream)) {
11
11
  return resultOrStream;
12
12
  }
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@envelop/execute-subscription-event",
3
- "version": "2.6.0",
3
+ "version": "2.6.1-alpha-20220901205925-b1fd44a9",
4
4
  "sideEffects": false,
5
5
  "peerDependencies": {
6
- "@envelop/core": "^2.6.0",
6
+ "@envelop/core": "2.6.1-alpha-20220901205925-b1fd44a9",
7
7
  "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
8
8
  },
9
9
  "dependencies": {