@graphql-mesh/http 0.1.13 → 0.1.14

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.
Files changed (3) hide show
  1. package/index.js +9 -13
  2. package/index.mjs +9 -13
  3. package/package.json +3 -3
package/index.js CHANGED
@@ -35,7 +35,7 @@ const graphqlHandler = (mesh$, playgroundTitle, playgroundEnabled, graphqlEndpoi
35
35
  }));
36
36
  return async (request, ...args) => {
37
37
  const yoga = await yoga$;
38
- return yoga.handleRequest(request, ...args);
38
+ return yoga.handle(request, ...args);
39
39
  };
40
40
  };
41
41
 
@@ -51,18 +51,14 @@ function createMeshHTTPHandler({ baseDir, getBuiltMesh, rawServeConfig = {}, pla
51
51
  // TODO
52
52
  // trustProxy = 'loopback',
53
53
  } = rawServeConfig;
54
- const router = ittyRouter.Router();
55
- const requestHandler = server.createServerAdapter({
56
- handleRequest: router.handle,
57
- baseObject: router,
58
- });
59
- router.all('/healthcheck', () => new fetch.Response(null, {
54
+ const serverAdapter = server.createServerAdapter(ittyRouter.Router());
55
+ serverAdapter.all('/healthcheck', () => new fetch.Response(null, {
60
56
  status: readyFlag ? 204 : 503,
61
57
  }));
62
- router.all('/readiness', () => new fetch.Response(null, {
58
+ serverAdapter.all('/readiness', () => new fetch.Response(null, {
63
59
  status: readyFlag ? 204 : 503,
64
60
  }));
65
- router.post('*', async (request) => {
61
+ serverAdapter.post('*', async (request) => {
66
62
  if (readyFlag) {
67
63
  const { pubsub } = await mesh$;
68
64
  for (const eventName of pubsub.getEventNames()) {
@@ -82,7 +78,7 @@ function createMeshHTTPHandler({ baseDir, getBuiltMesh, rawServeConfig = {}, pla
82
78
  });
83
79
  if (staticFiles) {
84
80
  const indexPath = crossHelpers.path.join(baseDir, staticFiles, 'index.html');
85
- router.get('*', async (request) => {
81
+ serverAdapter.get('*', async (request) => {
86
82
  const url = new URL(request.url);
87
83
  if (url.pathname === '/' && (await utils.pathExists(indexPath))) {
88
84
  const indexFile = await crossHelpers.fs.promises.readFile(indexPath);
@@ -104,15 +100,15 @@ function createMeshHTTPHandler({ baseDir, getBuiltMesh, rawServeConfig = {}, pla
104
100
  });
105
101
  }
106
102
  else {
107
- router.get('/', () => new fetch.Response(null, {
103
+ serverAdapter.get('/', () => new fetch.Response(null, {
108
104
  status: 302,
109
105
  headers: {
110
106
  Location: graphqlPath,
111
107
  },
112
108
  }));
113
109
  }
114
- router.all(graphqlPath, ittyRouterExtras.withCookies, graphqlHandler(mesh$, playgroundTitle, playgroundEnabled, graphqlPath, corsConfig));
115
- return requestHandler;
110
+ serverAdapter.all(graphqlPath, ittyRouterExtras.withCookies, graphqlHandler(mesh$, playgroundTitle, playgroundEnabled, graphqlPath, corsConfig));
111
+ return serverAdapter;
116
112
  }
117
113
 
118
114
  exports.createMeshHTTPHandler = createMeshHTTPHandler;
package/index.mjs CHANGED
@@ -31,7 +31,7 @@ const graphqlHandler = (mesh$, playgroundTitle, playgroundEnabled, graphqlEndpoi
31
31
  }));
32
32
  return async (request, ...args) => {
33
33
  const yoga = await yoga$;
34
- return yoga.handleRequest(request, ...args);
34
+ return yoga.handle(request, ...args);
35
35
  };
36
36
  };
37
37
 
@@ -47,18 +47,14 @@ function createMeshHTTPHandler({ baseDir, getBuiltMesh, rawServeConfig = {}, pla
47
47
  // TODO
48
48
  // trustProxy = 'loopback',
49
49
  } = rawServeConfig;
50
- const router = Router();
51
- const requestHandler = createServerAdapter({
52
- handleRequest: router.handle,
53
- baseObject: router,
54
- });
55
- router.all('/healthcheck', () => new Response(null, {
50
+ const serverAdapter = createServerAdapter(Router());
51
+ serverAdapter.all('/healthcheck', () => new Response(null, {
56
52
  status: readyFlag ? 204 : 503,
57
53
  }));
58
- router.all('/readiness', () => new Response(null, {
54
+ serverAdapter.all('/readiness', () => new Response(null, {
59
55
  status: readyFlag ? 204 : 503,
60
56
  }));
61
- router.post('*', async (request) => {
57
+ serverAdapter.post('*', async (request) => {
62
58
  if (readyFlag) {
63
59
  const { pubsub } = await mesh$;
64
60
  for (const eventName of pubsub.getEventNames()) {
@@ -78,7 +74,7 @@ function createMeshHTTPHandler({ baseDir, getBuiltMesh, rawServeConfig = {}, pla
78
74
  });
79
75
  if (staticFiles) {
80
76
  const indexPath = path.join(baseDir, staticFiles, 'index.html');
81
- router.get('*', async (request) => {
77
+ serverAdapter.get('*', async (request) => {
82
78
  const url = new URL(request.url);
83
79
  if (url.pathname === '/' && (await pathExists(indexPath))) {
84
80
  const indexFile = await fs.promises.readFile(indexPath);
@@ -100,15 +96,15 @@ function createMeshHTTPHandler({ baseDir, getBuiltMesh, rawServeConfig = {}, pla
100
96
  });
101
97
  }
102
98
  else {
103
- router.get('/', () => new Response(null, {
99
+ serverAdapter.get('/', () => new Response(null, {
104
100
  status: 302,
105
101
  headers: {
106
102
  Location: graphqlPath,
107
103
  },
108
104
  }));
109
105
  }
110
- router.all(graphqlPath, withCookies, graphqlHandler(mesh$, playgroundTitle, playgroundEnabled, graphqlPath, corsConfig));
111
- return requestHandler;
106
+ serverAdapter.all(graphqlPath, withCookies, graphqlHandler(mesh$, playgroundTitle, playgroundEnabled, graphqlPath, corsConfig));
107
+ return serverAdapter;
112
108
  }
113
109
 
114
110
  export { createMeshHTTPHandler };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-mesh/http",
3
- "version": "0.1.13",
3
+ "version": "0.1.14",
4
4
  "sideEffects": false,
5
5
  "peerDependencies": {
6
6
  "graphql": "*"
@@ -11,8 +11,8 @@
11
11
  "@graphql-mesh/types": "0.84.0",
12
12
  "@graphql-mesh/utils": "0.41.11",
13
13
  "@whatwg-node/fetch": "^0.4.3",
14
- "@whatwg-node/server": "0.3.0",
15
- "graphql-yoga": "3.0.0-alpha-20220905163021-e923bb34",
14
+ "@whatwg-node/server": "0.4.0",
15
+ "graphql-yoga": "3.0.0-alpha-20220917000718-4285245d",
16
16
  "itty-router": "2.6.1",
17
17
  "itty-router-extras": "0.4.2",
18
18
  "tslib": "^2.4.0"