@graphql-mesh/http 0.96.3 → 0.96.4-alpha-20230904122056-1177de280

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.
@@ -3,31 +3,38 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.graphqlHandler = void 0;
4
4
  const graphql_yoga_1 = require("graphql-yoga");
5
5
  const graphqlHandler = ({ getBuiltMesh, playgroundTitle, playgroundEnabled, graphqlEndpoint, corsConfig, batchingLimit, }) => {
6
+ let yoga;
6
7
  let yoga$;
7
8
  return (request, ctx) => {
9
+ if (yoga) {
10
+ return yoga.handleRequest(request, ctx);
11
+ }
8
12
  if (!yoga$) {
9
- yoga$ = getBuiltMesh().then(mesh => (0, graphql_yoga_1.createYoga)({
10
- plugins: [
11
- ...mesh.plugins,
12
- (0, graphql_yoga_1.useLogger)({
13
- skipIntrospection: true,
14
- logFn: (eventName, { args }) => {
15
- if (eventName.endsWith('-start')) {
16
- mesh.logger.debug(`\t headers: `, args.contextValue.headers);
17
- }
18
- },
19
- }),
20
- ],
21
- logging: mesh.logger,
22
- maskedErrors: false,
23
- graphiql: playgroundEnabled && {
24
- title: playgroundTitle,
25
- },
26
- cors: corsConfig,
27
- graphqlEndpoint,
28
- landingPage: false,
29
- batching: batchingLimit ? { limit: batchingLimit } : false,
30
- }));
13
+ yoga$ = getBuiltMesh().then(mesh => {
14
+ yoga = (0, graphql_yoga_1.createYoga)({
15
+ plugins: [
16
+ ...mesh.plugins,
17
+ (0, graphql_yoga_1.useLogger)({
18
+ skipIntrospection: true,
19
+ logFn: (eventName, { args }) => {
20
+ if (eventName.endsWith('-start')) {
21
+ mesh.logger.debug(`\t headers: `, args.contextValue.headers);
22
+ }
23
+ },
24
+ }),
25
+ ],
26
+ logging: mesh.logger,
27
+ maskedErrors: false,
28
+ graphiql: playgroundEnabled && {
29
+ title: playgroundTitle,
30
+ },
31
+ cors: corsConfig,
32
+ graphqlEndpoint,
33
+ landingPage: false,
34
+ batching: batchingLimit ? { limit: batchingLimit } : false,
35
+ });
36
+ return yoga;
37
+ });
31
38
  }
32
39
  return yoga$.then(yoga => yoga.handleRequest(request, ctx));
33
40
  };
@@ -1,30 +1,37 @@
1
1
  import { createYoga, useLogger } from 'graphql-yoga';
2
2
  export const graphqlHandler = ({ getBuiltMesh, playgroundTitle, playgroundEnabled, graphqlEndpoint, corsConfig, batchingLimit, }) => {
3
+ let yoga;
3
4
  let yoga$;
4
5
  return (request, ctx) => {
6
+ if (yoga) {
7
+ return yoga.handleRequest(request, ctx);
8
+ }
5
9
  if (!yoga$) {
6
- yoga$ = getBuiltMesh().then(mesh => createYoga({
7
- plugins: [
8
- ...mesh.plugins,
9
- useLogger({
10
- skipIntrospection: true,
11
- logFn: (eventName, { args }) => {
12
- if (eventName.endsWith('-start')) {
13
- mesh.logger.debug(`\t headers: `, args.contextValue.headers);
14
- }
15
- },
16
- }),
17
- ],
18
- logging: mesh.logger,
19
- maskedErrors: false,
20
- graphiql: playgroundEnabled && {
21
- title: playgroundTitle,
22
- },
23
- cors: corsConfig,
24
- graphqlEndpoint,
25
- landingPage: false,
26
- batching: batchingLimit ? { limit: batchingLimit } : false,
27
- }));
10
+ yoga$ = getBuiltMesh().then(mesh => {
11
+ yoga = createYoga({
12
+ plugins: [
13
+ ...mesh.plugins,
14
+ useLogger({
15
+ skipIntrospection: true,
16
+ logFn: (eventName, { args }) => {
17
+ if (eventName.endsWith('-start')) {
18
+ mesh.logger.debug(`\t headers: `, args.contextValue.headers);
19
+ }
20
+ },
21
+ }),
22
+ ],
23
+ logging: mesh.logger,
24
+ maskedErrors: false,
25
+ graphiql: playgroundEnabled && {
26
+ title: playgroundTitle,
27
+ },
28
+ cors: corsConfig,
29
+ graphqlEndpoint,
30
+ landingPage: false,
31
+ batching: batchingLimit ? { limit: batchingLimit } : false,
32
+ });
33
+ return yoga;
34
+ });
28
35
  }
29
36
  return yoga$.then(yoga => yoga.handleRequest(request, ctx));
30
37
  };
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@graphql-mesh/http",
3
- "version": "0.96.3",
3
+ "version": "0.96.4-alpha-20230904122056-1177de280",
4
4
  "sideEffects": false,
5
5
  "peerDependencies": {
6
6
  "@graphql-mesh/cross-helpers": "^0.4.0",
7
- "@graphql-mesh/runtime": "^0.96.2",
7
+ "@graphql-mesh/runtime": "0.96.3-alpha-20230904122056-1177de280",
8
8
  "@graphql-mesh/types": "^0.95.2",
9
9
  "@graphql-mesh/utils": "^0.95.2",
10
10
  "graphql": "*",
@@ -7,4 +7,4 @@ export declare const graphqlHandler: ({ getBuiltMesh, playgroundTitle, playgroun
7
7
  graphqlEndpoint: string;
8
8
  corsConfig: CORSOptions;
9
9
  batchingLimit?: number;
10
- }) => (request: Request, ctx: any) => Promise<Response>;
10
+ }) => (request: Request, ctx: any) => Response | Promise<Response>;
@@ -7,4 +7,4 @@ export declare const graphqlHandler: ({ getBuiltMesh, playgroundTitle, playgroun
7
7
  graphqlEndpoint: string;
8
8
  corsConfig: CORSOptions;
9
9
  batchingLimit?: number;
10
- }) => (request: Request, ctx: any) => Promise<Response>;
10
+ }) => (request: Request, ctx: any) => Response | Promise<Response>;