Skip to content

Commit

Permalink
Refactor the runtime (#7054)
Browse files Browse the repository at this point in the history
* Refactor the runtime

* Update versions

* chore(dependencies): updated changesets for modified dependencies

* Fix e2e tests

* Disposable executor

* chore(dependencies): updated changesets for modified dependencies

* Hold connections per context per source

* Go

* ESM instead of CJS

* chore(dependencies): updated changesets for modified dependencies

* Yarn.lock

* More refactor

* Cleanup

* chore(dependencies): updated changesets for modified dependencies

* Refactor and clean the logs in the unit tests

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
ardatan and github-actions[bot] authored Jun 13, 2024
1 parent b5bf97c commit 88d6232
Show file tree
Hide file tree
Showing 87 changed files with 1,344 additions and 1,357 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
dependencies updates:
- Added dependency [`@envelop/core@^5.0.1` ↗︎](https://www.npmjs.com/package/@envelop/core/v/5.0.1) (to `dependencies`)
- Added dependency [`@graphql-tools/executor@^1.2.6` ↗︎](https://www.npmjs.com/package/@graphql-tools/executor/v/1.2.6) (to `dependencies`)
- Added dependency [`@graphql-tools/federation@^1.1.36` ↗︎](https://www.npmjs.com/package/@graphql-tools/federation/v/1.1.36) (to `dependencies`)
6 changes: 6 additions & 0 deletions .changeset/@graphql-mesh_fusion-runtime-7054-dependencies.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@graphql-mesh/fusion-runtime": patch
---
dependencies updates:
- Added dependency [`@graphql-tools/federation@^2.0.0` ↗︎](https://www.npmjs.com/package/@graphql-tools/federation/v/2.0.0) (to `dependencies`)
- Added dependency [`disposablestack@^1.1.6` ↗︎](https://www.npmjs.com/package/disposablestack/v/1.1.6) (to `dependencies`)
5 changes: 5 additions & 0 deletions .changeset/@graphql-mesh_serve-cli-7054-dependencies.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@graphql-mesh/serve-cli": patch
---
dependencies updates:
- Removed dependency [`uWebSockets.js@uNetworking/uWebSockets.js#semver:^20` ↗︎](https://www.npmjs.com/package/uWebSockets.js/v/20.0.0) (from `dependencies`)
5 changes: 5 additions & 0 deletions .changeset/@graphql-mesh_serve-runtime-7009-dependencies.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@graphql-mesh/serve-runtime": patch
---
dependencies updates:
- Removed dependency [`@graphql-tools/federation@^1.1.36` ↗︎](https://www.npmjs.com/package/@graphql-tools/federation/v/1.1.36) (from `dependencies`)
5 changes: 5 additions & 0 deletions .changeset/@graphql-mesh_serve-runtime-7054-dependencies.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@graphql-mesh/serve-runtime": patch
---
dependencies updates:
- Added dependency [`disposablestack@^1.1.6` ↗︎](https://www.npmjs.com/package/disposablestack/v/1.1.6) (to `dependencies`)
5 changes: 5 additions & 0 deletions .changeset/@graphql-mesh_utils-7054-dependencies.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@graphql-mesh/utils": patch
---
dependencies updates:
- Added dependency [`disposablestack@^1.1.6` ↗︎](https://www.npmjs.com/package/disposablestack/v/1.1.6) (to `dependencies`)
6 changes: 6 additions & 0 deletions .changeset/fair-knives-float.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@graphql-mesh/compose-cli': minor
'@graphql-mesh/serve-cli': minor
---

Use ESM instead of CommonJS in CLI
6 changes: 6 additions & 0 deletions .changeset/modern-dolls-retire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@graphql-mesh/transport-rest': patch
---

Do not consume the uploaded file inside the fetch call, and pass it to the upstream directly as a
stream
21 changes: 21 additions & 0 deletions .changeset/poor-bikes-sleep.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
'@graphql-mesh/transform-hoist-field': patch
'@graphql-mesh/supergraph': patch
'@graphql-mesh/graphql': patch
'@graphql-mesh/mysql': patch
'@graphql-mesh/neo4j': patch
'@graphql-mesh/fusion-composition': patch
'@graphql-mesh/transport-common': patch
'@graphql-mesh/transport-mysql': patch
'@graphql-mesh/transport-neo4j': patch
'@graphql-mesh/fusion-runtime': patch
'@omnigraph/neo4j': patch
'@graphql-mesh/serve-runtime': patch
'@graphql-mesh/types': patch
'@graphql-mesh/utils': patch
'@graphql-mesh/plugin-hive': patch
'@graphql-mesh/cache-redis': patch
'@graphql-mesh/serve-cli': patch
---

Use `Disposable` pattern for plugins and transports
7 changes: 7 additions & 0 deletions .changeset/young-keys-heal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@graphql-mesh/plugin-newrelic': patch
'@graphql-mesh/runtime': patch
'@graphql-mesh/utils': patch
---

Simplify the code by using `mapMaybePromise`
2 changes: 0 additions & 2 deletions .github/workflows/loadtest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ name: loadtest

on:
pull_request:
branches:
- master
push:
branches:
- master
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
name: pr
on:
pull_request:
branches:
- master

jobs:
dependencies:
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
name: test
on:
pull_request:
branches:
- master
push:
branches:
- master
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ on:
branches:
- master
pull_request:
branches:
- master

jobs:
deployment:
Expand Down
4 changes: 4 additions & 0 deletions .prettierrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@ const guildConfig = require('@theguild/prettier-config');
module.exports = {
...guildConfig,
overrides: [{ files: '*.json', options: { trailingComma: 'none' } }, ...guildConfig.overrides],
importOrderParserPlugins: [
'explicitResourceManagement',
...guildConfig.importOrderParserPlugins,
]
};
5 changes: 4 additions & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@ module.exports = {
['@babel/preset-env', { targets: { node: process.versions.node.split('.')[0] } }],
'@babel/preset-typescript',
],
plugins: ['@babel/plugin-proposal-class-properties'],
plugins: [
'@babel/plugin-proposal-class-properties',
'@babel/plugin-proposal-explicit-resource-management',
],
};
5 changes: 5 additions & 0 deletions declarations.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,8 @@ declare module 'newrelic/*' {
declare module '@newrelic/test-utilities' {
export const TestAgent: any;
}

declare module 'disposablestack/AsyncDisposableStack' {
declare var AsyncDisposableStackCtor: typeof AsyncDisposableStack;
export = AsyncDisposableStackCtor;
}
1 change: 0 additions & 1 deletion e2e/json-schema-subscriptions/mesh.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ export const composeConfig = defineComposeConfig({
});

export const serveConfig = defineServeConfig({
fusiongraph: '', // TODO: dont require fusiongraph option since it can be provided from as a CLI arg
pubsub: new PubSub(),
plugins: ctx => [
useWebhooks(ctx),
Expand Down
7 changes: 0 additions & 7 deletions e2e/mysql-rfam/mesh.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { defineConfig as defineComposeConfig } from '@graphql-mesh/compose-cli';
import { defineConfig as defineServeConfig } from '@graphql-mesh/serve-cli';
import { PubSub } from '@graphql-mesh/utils';
import { loadMySQLSubgraph } from '@omnigraph/mysql';

export const composeConfig = defineComposeConfig({
Expand All @@ -12,8 +10,3 @@ export const composeConfig = defineComposeConfig({
},
],
});

export const serveConfig = defineServeConfig({
fusiongraph: '', // TODO: dont require fusiongraph option since it can be provided from as a CLI arg
pubsub: new PubSub(),
});
7 changes: 0 additions & 7 deletions e2e/neo4j-example/mesh.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { defineConfig as defineComposeConfig } from '@graphql-mesh/compose-cli';
import { defineConfig as defineServeConfig } from '@graphql-mesh/serve-cli';
import { PubSub } from '@graphql-mesh/utils';
import { loadNeo4JSubgraph } from '@omnigraph/neo4j';

export const composeConfig = defineComposeConfig({
Expand All @@ -18,8 +16,3 @@ export const composeConfig = defineComposeConfig({
},
],
});

export const serveConfig = defineServeConfig({
fusiongraph: '', // TODO: dont require fusiongraph option since it can be provided from as a CLI arg
pubsub: new PubSub(),
});
1 change: 0 additions & 1 deletion e2e/openapi-javascript-wiki/mesh.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export const composeConfig = defineComposeConfig({
});

export const serveConfig = defineServeConfig({
fusiongraph: '', // TODO: dont require fusiongraph option since it can be provided from as a CLI arg
additionalResolvers: {
Query: {
async viewsInPastMonth(root, { project }, context: any, info) {
Expand Down
1 change: 0 additions & 1 deletion e2e/openapi-subscriptions/mesh.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export const composeConfig = defineComposeConfig({
});

export const serveConfig = defineServeConfig({
fusiongraph: '', // TODO: dont require fusiongraph option since it can be provided from as a CLI arg
pubsub: new PubSub(),
plugins: ctx => [useWebhooks(ctx)],
});
101 changes: 0 additions & 101 deletions e2e/pubsub-destroy/CHANGELOG.md

This file was deleted.

16 changes: 0 additions & 16 deletions e2e/pubsub-destroy/mesh.config.ts

This file was deleted.

8 changes: 0 additions & 8 deletions e2e/pubsub-destroy/package.json

This file was deleted.

8 changes: 0 additions & 8 deletions e2e/pubsub-destroy/pubsub-destroy.test.ts

This file was deleted.

1 change: 0 additions & 1 deletion examples/grpc-example/tests/grpc.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'json-bigint-patch';
import { join } from 'path';
import { readFile } from 'fs-extra';
import { findAndParseConfig } from '@graphql-mesh/cli';
Expand Down
3 changes: 2 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ if (process.env.E2E_TEST) {
} else {
testMatch.push('!**/e2e/**/?(*.)+(spec|test).[jt]s?(x)');
}

/** @type {import('jest').Config} */
module.exports = {
prettierPath: null, // not supported before Jest v30 https://github.com/jestjs/jest/issues/14305
testEnvironment: 'node',
Expand All @@ -65,4 +65,5 @@ module.exports = {
},
resolver: 'bob-the-bundler/jest-resolver',
testMatch,
setupFilesAfterEnv: ['<rootDir>/setup-jest.js'],
};
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
"@ardatan/graphql-to-config-schema": "0.1.25",
"@babel/core": "7.24.7",
"@babel/plugin-proposal-class-properties": "7.18.6",
"@babel/plugin-proposal-explicit-resource-management": "7.24.7",
"@babel/preset-env": "7.24.7",
"@babel/preset-typescript": "7.24.7",
"@changesets/changelog-github": "0.5.0",
Expand Down
15 changes: 6 additions & 9 deletions packages/cache/redis/__integration_tests__/redis.spec.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
import RedisCache from '@graphql-mesh/cache-redis';
import { DefaultLogger, PubSub } from '@graphql-mesh/utils';
import { DefaultLogger } from '@graphql-mesh/utils';

describe('Redis', () => {
const pubsub = new PubSub();
const logger = new DefaultLogger('test');
const redisCache = new RedisCache<any>({
host: '{env.REDIS_HOST}',
port: '{env.REDIS_PORT}',
pubsub,
logger,
});
afterAll(() => pubsub.publish('destroy', undefined));
it('works', async () => {
using redisCache = new RedisCache<any>({
host: '{env.REDIS_HOST}',
port: '{env.REDIS_PORT}',
logger,
});
const test = await redisCache.get('test');
expect(test).toBeUndefined();
const now = Date.now();
Expand Down
Loading

0 comments on commit 88d6232

Please sign in to comment.