@envelop/execute-subscription-event 2.4.0-alpha-e9434aa.0 → 2.4.0-alpha-731c100.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/esm/index.js CHANGED
@@ -1,17 +1,14 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useExtendContextValuePerExecuteSubscriptionEvent = void 0;
4
- const graphql_1 = require("graphql");
5
- const core_1 = require("@envelop/core");
6
- const subscribe_js_1 = require("./subscribe.js");
7
- const useExtendContextValuePerExecuteSubscriptionEvent = (createContext) => {
1
+ import { execute } from 'graphql';
2
+ import { makeExecute } from '@envelop/core';
3
+ import { subscribe } from './subscribe.js';
4
+ export const useExtendContextValuePerExecuteSubscriptionEvent = (createContext) => {
8
5
  return {
9
6
  onSubscribe({ args, setSubscribeFn }) {
10
- const executeNew = (0, core_1.makeExecute)(async (executionArgs) => {
7
+ const executeNew = makeExecute(async (executionArgs) => {
11
8
  var _a;
12
9
  const context = await createContext({ args });
13
10
  try {
14
- return await (0, graphql_1.execute)({
11
+ return await execute({
15
12
  ...executionArgs,
16
13
  // GraphQL.js 16 changed the type of contextValue to unknown
17
14
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -23,8 +20,7 @@ const useExtendContextValuePerExecuteSubscriptionEvent = (createContext) => {
23
20
  (_a = context === null || context === void 0 ? void 0 : context.onEnd) === null || _a === void 0 ? void 0 : _a.call(context);
24
21
  }
25
22
  });
26
- setSubscribeFn((0, subscribe_js_1.subscribe)(executeNew));
23
+ setSubscribeFn(subscribe(executeNew));
27
24
  },
28
25
  };
29
26
  };
30
- exports.useExtendContextValuePerExecuteSubscriptionEvent = useExtendContextValuePerExecuteSubscriptionEvent;
package/esm/subscribe.js CHANGED
@@ -1,16 +1,13 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.subscribe = void 0;
4
- const graphql_1 = require("graphql");
5
- const core_1 = require("@envelop/core");
1
+ import { createSourceEventStream } from 'graphql';
2
+ import { makeSubscribe, mapAsyncIterator, isAsyncIterable } from '@envelop/core';
6
3
  /**
7
4
  * This is a almost identical port from graphql-js subscribe.
8
5
  * The only difference is that a custom `execute` function can be injected for customizing the behavior.
9
6
  */
10
- const subscribe = (execute) => (0, core_1.makeSubscribe)(async (args) => {
7
+ export const subscribe = (execute) => makeSubscribe(async (args) => {
11
8
  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);
13
- if (!(0, core_1.isAsyncIterable)(resultOrStream)) {
9
+ const resultOrStream = await createSourceEventStream(schema, document, rootValue, contextValue, variableValues !== null && variableValues !== void 0 ? variableValues : undefined, operationName, subscribeFieldResolver);
10
+ if (!isAsyncIterable(resultOrStream)) {
14
11
  return resultOrStream;
15
12
  }
16
13
  // For each payload yielded from a subscription, map it over the normal
@@ -29,6 +26,5 @@ const subscribe = (execute) => (0, core_1.makeSubscribe)(async (args) => {
29
26
  fieldResolver,
30
27
  });
31
28
  // Map every source value to a ExecutionResult value as described above.
32
- return (0, core_1.mapAsyncIterator)(resultOrStream, mapSourceToResponse);
29
+ return mapAsyncIterator(resultOrStream, mapSourceToResponse);
33
30
  });
34
- exports.subscribe = subscribe;
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@envelop/execute-subscription-event",
3
- "version": "2.4.0-alpha-e9434aa.0",
3
+ "version": "2.4.0-alpha-731c100.0",
4
4
  "sideEffects": false,
5
5
  "peerDependencies": {
6
- "@envelop/core": "2.4.0-alpha-e9434aa.0",
6
+ "@envelop/core": "2.4.0-alpha-731c100.0",
7
7
  "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
8
8
  },
9
9
  "dependencies": {},