@graphql-yoga/plugin-sofa 3.13.0 → 3.13.1

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/cjs/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useSofa = useSofa;
4
- const graphql_yoga_1 = require("graphql-yoga");
5
4
  const sofa_api_1 = require("sofa-api");
5
+ const promise_helpers_1 = require("@whatwg-node/promise-helpers");
6
6
  function useSofa(config) {
7
7
  let sofaHandler;
8
8
  let getEnveloped;
@@ -17,7 +17,7 @@ function useSofa(config) {
17
17
  schema: onSchemaChangeEventPayload.schema,
18
18
  context(serverContext) {
19
19
  const enveloped = getEnveloped(serverContext);
20
- return (0, graphql_yoga_1.mapMaybePromise)(enveloped.contextFactory(serverContext), contextValue$ => {
20
+ return (0, promise_helpers_1.handleMaybePromise)(() => enveloped.contextFactory(serverContext), contextValue$ => {
21
21
  envelopedByContext.set(contextValue$, enveloped);
22
22
  return contextValue$;
23
23
  });
@@ -62,12 +62,13 @@ function useSofa(config) {
62
62
  },
63
63
  });
64
64
  },
65
- async onRequest({ request, endResponse, serverContext, url }) {
65
+ onRequest({ request, endResponse, serverContext, url }) {
66
66
  if (url.pathname.startsWith(config.basePath)) {
67
- const res = await sofaHandler.handleRequest(request, serverContext);
68
- if (res) {
69
- endResponse(res);
70
- }
67
+ return (0, promise_helpers_1.handleMaybePromise)(() => sofaHandler.handleRequest(request, serverContext), res => {
68
+ if (res) {
69
+ endResponse(res);
70
+ }
71
+ });
71
72
  }
72
73
  },
73
74
  };
package/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { mapMaybePromise } from 'graphql-yoga';
2
1
  import { useSofa as createSofaHandler } from 'sofa-api';
2
+ import { handleMaybePromise } from '@whatwg-node/promise-helpers';
3
3
  export function useSofa(config) {
4
4
  let sofaHandler;
5
5
  let getEnveloped;
@@ -14,7 +14,7 @@ export function useSofa(config) {
14
14
  schema: onSchemaChangeEventPayload.schema,
15
15
  context(serverContext) {
16
16
  const enveloped = getEnveloped(serverContext);
17
- return mapMaybePromise(enveloped.contextFactory(serverContext), contextValue$ => {
17
+ return handleMaybePromise(() => enveloped.contextFactory(serverContext), contextValue$ => {
18
18
  envelopedByContext.set(contextValue$, enveloped);
19
19
  return contextValue$;
20
20
  });
@@ -59,12 +59,13 @@ export function useSofa(config) {
59
59
  },
60
60
  });
61
61
  },
62
- async onRequest({ request, endResponse, serverContext, url }) {
62
+ onRequest({ request, endResponse, serverContext, url }) {
63
63
  if (url.pathname.startsWith(config.basePath)) {
64
- const res = await sofaHandler.handleRequest(request, serverContext);
65
- if (res) {
66
- endResponse(res);
67
- }
64
+ return handleMaybePromise(() => sofaHandler.handleRequest(request, serverContext), res => {
65
+ if (res) {
66
+ endResponse(res);
67
+ }
68
+ });
68
69
  }
69
70
  },
70
71
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-yoga/plugin-sofa",
3
- "version": "3.13.0",
3
+ "version": "3.13.1",
4
4
  "description": "",
5
5
  "peerDependencies": {
6
6
  "graphql": "^15.2.0 || ^16.0.0",
@@ -8,6 +8,7 @@
8
8
  },
9
9
  "dependencies": {
10
10
  "@graphql-tools/utils": "^10.3.2",
11
+ "@whatwg-node/promise-helpers": "^1.2.4",
11
12
  "sofa-api": "^0.18.8"
12
13
  },
13
14
  "repository": {