Skip to content

Commit 3cdd0aa

Browse files
ardatanenisdenjorenovate[bot]github-actions[bot]theguild-bot
authored
Hive Gateway Driver for NestJS (#667)
Co-authored-by: Denis Badurina <[email protected]> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: theguild-bot <[email protected]>
1 parent f974f5b commit 3cdd0aa

File tree

17 files changed

+1894
-58
lines changed

17 files changed

+1894
-58
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
'@graphql-hive/gateway': patch
3+
---
4+
5+
dependencies updates:
6+
7+
- Updated dependency [`@graphql-mesh/cache-localforage@^0.104.0` ↗︎](https://www.npmjs.com/package/@graphql-mesh/cache-localforage/v/0.104.0) (from `^0.103.19`, in `dependencies`)
8+
- Updated dependency [`@graphql-mesh/cache-upstash-redis@^0.0.6` ↗︎](https://www.npmjs.com/package/@graphql-mesh/cache-upstash-redis/v/0.0.6) (from `^0.0.5`, in `dependencies`)
9+
- Updated dependency [`@graphql-mesh/plugin-mock@^0.104.0` ↗︎](https://www.npmjs.com/package/@graphql-mesh/plugin-mock/v/0.104.0) (from `^0.103.19`, in `dependencies`)

.changeset/sixty-camels-design.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@graphql-hive/nestjs': major
3+
---
4+
5+
Hive Gateway Driver for NestJS;
6+
7+
[Learn more in the docs](https://the-guild.dev/graphql/hive/docs/gateway/deployment/node-frameworks/nestjs)

.changeset/small-lies-beg.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@graphql-hive/gateway': minor
3+
---
4+
5+
Expose internal methods `getCacheInstanceFromConfig` and `getBuiltinPluginsFromConfig`

babel.config.cjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ module.exports = {
77
'@babel/preset-typescript',
88
],
99
plugins: [
10+
['@babel/plugin-transform-class-static-block', { version: '2023-11' }],
11+
['@babel/plugin-proposal-decorators', { version: '2023-11' }],
1012
'@babel/plugin-transform-class-properties',
1113
'@babel/plugin-proposal-explicit-resource-management',
1214
],

e2e/nestjs/nestjs.e2e.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { createExampleSetup, createTenv } from '@internal/e2e';
2+
import { getLocalhost } from '@internal/testing';
3+
import { fetch } from '@whatwg-node/fetch';
4+
import { expect, it } from 'vitest';
5+
6+
const { service } = createTenv(__dirname);
7+
const { supergraph, query, result } = createExampleSetup(__dirname);
8+
9+
it.todo('executes the query', async () => {
10+
const supergraphPath = await supergraph();
11+
const { port } = await service('nestjs', {
12+
args: [`--supergraph=${supergraphPath}`],
13+
});
14+
const hostname = await getLocalhost(port);
15+
const response = await fetch(`${hostname}:${port}/graphql`, {
16+
method: 'POST',
17+
headers: {
18+
'Content-Type': 'application/json',
19+
},
20+
body: JSON.stringify({
21+
query,
22+
}),
23+
});
24+
if (!response.ok) {
25+
throw new Error(`HTTP error: ${response.status}: ${await response.text()}`);
26+
}
27+
const received = await response.json();
28+
expect(received).toEqual(result);
29+
});

e2e/nestjs/package.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "@e2e/nestjs",
3+
"version": "0.0.1",
4+
"private": true,
5+
"dependencies": {
6+
"@graphql-hive/nestjs": "workspace:^",
7+
"@nestjs/common": "^11.0.10",
8+
"@nestjs/core": "^11.0.10",
9+
"@nestjs/graphql": "^13.0.3",
10+
"@nestjs/platform-express": "^11.0.10",
11+
"graphql": "^16.10.0",
12+
"reflect-metadata": "^0.2.2",
13+
"rxjs": "^7.8.1"
14+
}
15+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import {
2+
HiveGatewayDriver,
3+
HiveGatewayDriverConfig,
4+
} from '@graphql-hive/nestjs';
5+
import { Opts } from '@internal/testing';
6+
import { Module } from '@nestjs/common';
7+
import { GraphQLModule } from '@nestjs/graphql';
8+
9+
const opts = Opts(process.argv);
10+
const supergraph = opts.get('supergraph', true);
11+
12+
@Module({
13+
imports: [
14+
GraphQLModule.forRoot<HiveGatewayDriverConfig>({
15+
driver: HiveGatewayDriver,
16+
supergraph,
17+
}),
18+
],
19+
})
20+
export class AppModule {}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { Opts } from '@internal/testing';
2+
import { NestFactory } from '@nestjs/core';
3+
import { AppModule } from './app.module';
4+
5+
const opts = Opts(process.argv);
6+
const port = opts.getServicePort('nestjs', true);
7+
8+
async function main() {
9+
const app = await NestFactory.create(AppModule);
10+
await app.listen(port);
11+
}
12+
13+
main().catch((err) => {
14+
console.error(err);
15+
process.exit(1);
16+
});

jest.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const rootDir = __dirname;
99
const tsconfigPath = resolve(rootDir, 'tsconfig.json');
1010
const tsconfigContents = readFileSync(tsconfigPath, 'utf8');
1111
const tsconfig = JSON5.parse(tsconfigContents);
12-
const ESM_PACKAGES = ['graphql-federation-gateway-audit'];
12+
const ESM_PACKAGES = ['graphql-federation-gateway-audit', 'parse-duration'];
1313

1414
export default {
1515
testEnvironment: 'node',

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@
2727
},
2828
"devDependencies": {
2929
"@babel/core": "7.26.9",
30+
"@babel/plugin-proposal-decorators": "7.25.9",
3031
"@babel/plugin-proposal-explicit-resource-management": "7.25.9",
3132
"@babel/plugin-transform-class-properties": "7.25.9",
33+
"@babel/plugin-transform-class-static-block": "7.26.0",
3234
"@babel/preset-env": "7.26.9",
3335
"@babel/preset-typescript": "7.26.0",
3436
"@changesets/changelog-github": "^0.5.0",

0 commit comments

Comments
 (0)