Skip to content

Commit

Permalink
[v0] - remove uWS.js and node-libcurl, remove extra logic for stitchi…
Browse files Browse the repository at this point in the history
…ng (#7887)

* [v0] -  remove uWS.js and node-libcurl, remove extra logic for stitching

* chore(dependencies): updated changesets for modified dependencies

* Fix tests

* Fix integration tests

* Go

* COntinue

* Hello

* More

* ..

* Fix e2e for Node 18

* Again

* Attempt

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
ardatan and github-actions[bot] authored Nov 5, 2024
1 parent 4325519 commit ac82d44
Show file tree
Hide file tree
Showing 50 changed files with 223 additions and 4,953 deletions.
5 changes: 5 additions & 0 deletions .changeset/@graphql-mesh_cli-7887-dependencies.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@graphql-mesh/cli": patch
---
dependencies updates:
- Removed dependency [`node-libcurl@npm:@ardatan/node-libcurl@^4.0.2` ↗︎](https://www.npmjs.com/package/node-libcurl/v/4.0.2) (from `dependencies`)
8 changes: 8 additions & 0 deletions .changeset/selfish-impalas-call.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@graphql-mesh/merger-stitching': minor
'@graphql-mesh/merger-bare': minor
'@graphql-mesh/runtime': minor
'@graphql-mesh/cli': minor
---

Relax runtime and CLI packages, remove node-libcurl and uWebSockets
5 changes: 0 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,6 @@ jobs:
restore-keys: |
${{runner.os}}-${{matrix.node-version}}-jest-unit-
- name: Remove node-libcurl
run: rm -rf node_modules/node-libcurl

- name: Prepare for build
run: yarn prebuild

Expand Down Expand Up @@ -290,8 +287,6 @@ jobs:
run: yarn build
- name: Build Test Artifacts
run: yarn build-test-artifacts
- name: Remove node-libcurl
run: rm -rf node_modules/node-libcurl
- name: Run Tests
uses: nick-fields/retry@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion e2e/cjs-project/cjs-project.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ it('should serve', async () => {
const proc = await serve({
supergraph: await fs.tempfile('supergraph.graphql', 'type Query { hello: String }'),
});
const res = await fetch(`http://localhost:${proc.port}/healthcheck`);
const res = await fetch(`http://${proc.hostname}:${proc.port}/healthcheck`);
expect(res.ok).toBeTruthy();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ it('should serve', async () => {
const proc = await serve({
supergraph: await fs.tempfile('supergraph.graphql', 'type Query { hello: String }'),
});
const res = await fetch(`http://localhost:${proc.port}/healthcheck`);
const res = await fetch(`http://${proc.hostname}:${proc.port}/healthcheck`);
expect(res.ok).toBeTruthy();
});

Expand Down
2 changes: 1 addition & 1 deletion e2e/esm-project/esm-project.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ it('should serve', async () => {
const proc = await serve({
supergraph: await fs.tempfile('supergraph.graphql', 'type Query { hello: String }'),
});
const res = await fetch(`http://localhost:${proc.port}/healthcheck`);
const res = await fetch(`http://${proc.hostname}:${proc.port}/healthcheck`);
expect(res.ok).toBeTruthy();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ subscriptionsClientFactories.forEach(([protocol, createClient]) => {
await service('products'),
await service('reviews'),
]);
const { port } = await serve({ supergraph: supergraphFile });
const { hostname, port } = await serve({ supergraph: supergraphFile });

client = createClient({
url: `http://localhost:${port}/graphql`,
url: `http://${hostname}:${port}/graphql`,
retryAttempts: 0,
headers,
connectionParams: headers,
Expand Down Expand Up @@ -129,10 +129,10 @@ subscriptionsClientFactories.forEach(([protocol, createClient]) => {
await service('products'),
await service('reviews'),
]);
const { port } = await serve({ supergraph: supergraphFile });
const { hostname, port } = await serve({ supergraph: supergraphFile });

client = createClient({
url: `http://localhost:${port}/graphql`,
url: `http://${hostname}:${port}/graphql`,
retryAttempts: 0,
headers,
connectionParams: headers,
Expand Down
4 changes: 2 additions & 2 deletions e2e/file-upload/file-upload.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const { compose, serve, service } = createTenv(__dirname);

it('should upload file', async () => {
const { output } = await compose({ output: 'graphql', services: [await service('bucket')] });
const { port } = await serve({ supergraph: output });
const { hostname, port } = await serve({ supergraph: output });

const form = new FormData();
form.append(
Expand All @@ -23,7 +23,7 @@ it('should upload file', async () => {
);
form.append('map', JSON.stringify({ 0: ['variables.file'] }));
form.append('0', new File(['Hello World!'], 'hello.txt', { type: 'text/plain' }));
const res = await fetch(`http://localhost:${port}/graphql`, {
const res = await fetch(`http://${hostname}:${port}/graphql`, {
method: 'POST',
body: form,
});
Expand Down
8 changes: 4 additions & 4 deletions e2e/grpc-example/grpc-example.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ describe('gRPC Example', () => {
});
it('streams movies by cast correctly', async () => {
const { output } = await compose({ services: [movies], output: 'graphql' });
const { port } = await serve({ supergraph: output });
const { hostname, port } = await serve({ supergraph: output });
const executor = buildHTTPExecutor({
endpoint: `http://localhost:${port}/graphql`,
endpoint: `http://${hostname}:${port}/graphql`,
});
const document = parse(/* GraphQL */ `
query SearchMoviesByCast {
Expand All @@ -65,9 +65,9 @@ describe('gRPC Example', () => {
});
it('fetches movies by cast as a subscription correctly', async () => {
const { output } = await compose({ services: [movies], output: 'graphql' });
const { port } = await serve({ supergraph: output });
const { hostname, port } = await serve({ supergraph: output });
const executor = buildHTTPExecutor({
endpoint: `http://localhost:${port}/graphql`,
endpoint: `http://${hostname}:${port}/graphql`,
});
const document = parse(/* GraphQL */ `
subscription SearchMoviesByCast {
Expand Down
3 changes: 2 additions & 1 deletion e2e/grpc-example/services/movies/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { dirname, join } from 'path';
import { setTimeout } from 'timers/promises';
import { fileURLToPath } from 'url';
import { Opts } from '@e2e/opts';
import {
Expand Down Expand Up @@ -82,7 +83,7 @@ async function startServer(subscriptionInterval = 1000, debug = false): Promise<
call.end();
});
for (const movie of Movies) {
await new Promise(resolve => setTimeout(resolve, subscriptionInterval));
await setTimeout(subscriptionInterval);
if (call.cancelled || call.destroyed) {
logger('call ended');
return;
Expand Down
4 changes: 2 additions & 2 deletions e2e/js-config/js-config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ it('should compose and serve', async () => {

const supergraphPath = await fs.tempfile('supergraph.graphql');
await fs.write(supergraphPath, composedSchema);
const { port } = await serve({ supergraph: supergraphPath });
const res = await fetch(`http://localhost:${port}/graphql?query={hello}`);
const { hostname, port } = await serve({ supergraph: supergraphPath });
const res = await fetch(`http://${hostname}:${port}/graphql?query={hello}`);
expect(res.ok).toBeTruthy();
await expect(res.text()).resolves.toMatchInlineSnapshot(`"{"data":{"hello":"world"}}"`);
});
10 changes: 6 additions & 4 deletions e2e/json-schema-subscriptions/json-schema-subscriptions.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { createClient } from 'graphql-sse';
import { createTenv, getAvailablePort } from '@e2e/tenv';
import { createTenv } from '@e2e/tenv';
import { fetch } from '@whatwg-node/fetch';
import { getAvailablePort } from '../../packages/testing/getAvailablePort';

const { compose, serve, service } = createTenv(__dirname);

it('should compose the appropriate schema', async () => {
const { result } = await compose({ services: [await service('api')], maskServicePorts: true });
const api = await service('api');
const { result } = await compose({ services: [api], maskServicePorts: true });
expect(result).toMatchSnapshot();
});

Expand All @@ -15,7 +17,7 @@ it('should compose the appropriate schema', async () => {
const servePort = await getAvailablePort();
const api = await service('api', { servePort });
const { output } = await compose({ output: 'graphql', services: [api] });
const { execute } = await serve({ supergraph: output, port: servePort });
const { hostname, port, execute } = await serve({ supergraph: output, port: servePort });

await expect(
execute({
Expand All @@ -37,7 +39,7 @@ it('should compose the appropriate schema', async () => {
`);

const sse = createClient({
url: `http://localhost:${servePort}/graphql`,
url: `http://${hostname}:${port}/graphql`,
retryAttempts: 0,
fetchFn: fetch,
});
Expand Down
40 changes: 22 additions & 18 deletions e2e/json-schema-subscriptions/services/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { createServer } from 'http';
import { createRouter, Response } from 'fets';
import { Opts } from '@e2e/opts';
import { fetch } from '@whatwg-node/fetch';
import { getLocalHostName } from '../../../packages/testing/getLocalHostName';

const opts = Opts(process.argv);

Expand All @@ -23,25 +24,28 @@ const app = createRouter<FetchEvent>()
...reqBody,
};
todos.push(todo);
const port = opts.getPort(true);
waitUntil(
fetch(`http://localhost:${opts.getPort(true)}/webhooks/todo_added`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(todo),
})
.then(res =>
res.text().then(resText =>
console.log('Webhook payload sent', {
status: res.status,
statusText: res.statusText,
body: resText,
headers: Object.fromEntries(res.headers.entries()),
}),
),
)
.catch(err => console.error('Webhook payload failed', err)),
getLocalHostName(port).then(hostname =>
fetch(`http://${hostname}:${port}/webhooks/todo_added`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(todo),
})
.then(res =>
res.text().then(resText =>
console.log('Webhook payload sent', {
status: res.status,
statusText: res.statusText,
body: resText,
headers: Object.fromEntries(res.headers.entries()),
}),
),
)
.catch(err => console.error('Webhook payload failed', err)),
),
);
return Response.json(todo);
},
Expand Down
6 changes: 3 additions & 3 deletions e2e/openapi-subscriptions/openapi-subscriptions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ it('should compose the appropriate schema', async () => {

it('should listen for webhooks', async () => {
const { output } = await compose({ output: 'graphql', services: [await service('api')] });
const { execute, port } = await serve({ supergraph: output });
const { hostname, execute, port } = await serve({ supergraph: output });

const res = await execute({
query: /* GraphQL */ `
Expand All @@ -25,15 +25,15 @@ it('should listen for webhooks', async () => {
}
`,
variables: {
url: `http://localhost:${port.toString()}/callback`,
url: `http://${hostname}:${port.toString()}/callback`,
},
});

const subscriptionId = res.data?.post_streams?.subscriptionId;
expect(subscriptionId).toBeTruthy();

const sse = createClient({
url: `http://localhost:${port}/graphql`,
url: `http://${hostname}:${port}/graphql`,
retryAttempts: 0,
fetchFn: fetch,
});
Expand Down
9 changes: 4 additions & 5 deletions e2e/opentelemetry/opentelemetry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,15 +282,14 @@ describe('opentelemetry', () => {

it('should report http failures', async () => {
const serviceName = 'mesh-e2e-test-4';
const { port } = await serve({
const { hostname, port } = await serve({
supergraph,
env: {
OTLP_EXPORTER_URL: `http://localhost:${jaeger.port}/v1/traces`,
OTLP_SERVICE_NAME: serviceName,
},
});

await fetch(`http://localhost:${port}/non-existing`).catch(() => {});
await fetch(`http://${hostname}:${port}/non-existing`).catch(() => {});
const traces = await getJaegerTraces(serviceName, 2);
expect(traces.data.length).toBe(2);
const relevantTrace = traces.data.find(trace =>
Expand Down Expand Up @@ -323,7 +322,7 @@ describe('opentelemetry', () => {
it('context propagation should work correctly', async () => {
const traceId = '0af7651916cd43dd8448eb211c80319c';
const serviceName = 'mesh-e2e-test-5';
const { execute, port } = await serve({
const { execute, hostname, port } = await serve({
supergraph,
env: {
OTLP_EXPORTER_URL: `http://localhost:${jaeger.port}/v1/traces`,
Expand All @@ -340,7 +339,7 @@ describe('opentelemetry', () => {
}),
).resolves.toMatchSnapshot();

const upstreamHttpCalls = await fetch(`http://localhost:${port}/upstream-fetch`).then(r =>
const upstreamHttpCalls = await fetch(`http://${hostname}:${port}/upstream-fetch`).then(r =>
r.json<
Array<{
url: string;
Expand Down
2 changes: 1 addition & 1 deletion e2e/top-level-await/top-level-await.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ it('should serve', async () => {
const proc = await serve({
supergraph: await fs.tempfile('supergraph.graphql', 'type Query { hello: String }'),
});
const res = await fetch(`http://localhost:${proc.port}/healthcheck`);
const res = await fetch(`http://${proc.hostname}:${proc.port}/healthcheck`);
expect(res.ok).toBeTruthy();
});

Expand Down
Loading

0 comments on commit ac82d44

Please sign in to comment.