Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .changeset/@graphql-hive_gateway-712-dependencies.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'@graphql-hive/gateway': patch
---

dependencies updates:

- 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`)
- 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`)
- 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`)
Comment on lines +5 to +9
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Document Dependency Updates
The updated dependency versions (with links to the npm packages) are clearly listed, which is very helpful. For additional clarity, consider including a short rationale for these updates to assist downstream consumers in understanding the context of these changes.

7 changes: 7 additions & 0 deletions .changeset/sixty-camels-design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@graphql-hive/nestjs': major
---

Hive Gateway Driver for NestJS;

[Learn more in the docs](https://the-guild.dev/graphql/hive/docs/gateway/deployment/node-frameworks/nestjs)
Comment on lines +5 to +7
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Enhance Description for Hive Gateway Driver
The brief description and documentation link provide a good start, but given that documentation is currently missing (as noted in PR objectives), consider expanding the description or opening a follow-up issue to add comprehensive documentation in the console project. Also, ensure the GW-133 ticket reference is clearly noted elsewhere in project management.

5 changes: 5 additions & 0 deletions .changeset/small-lies-beg.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphql-hive/gateway': minor
---

Expose internal methods `getCacheInstanceFromConfig` and `getBuiltinPluginsFromConfig`
2 changes: 2 additions & 0 deletions babel.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ module.exports = {
'@babel/preset-typescript',
],
plugins: [
['@babel/plugin-transform-class-static-block', { version: '2023-11' }],
['@babel/plugin-proposal-decorators', { version: '2023-11' }],
'@babel/plugin-transform-class-properties',
'@babel/plugin-proposal-explicit-resource-management',
],
Expand Down
29 changes: 29 additions & 0 deletions e2e/nestjs/nestjs.e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { createExampleSetup, createTenv } from '@internal/e2e';
import { getLocalhost } from '@internal/testing';
import { fetch } from '@whatwg-node/fetch';
import { expect, it } from 'vitest';

const { service } = createTenv(__dirname);
const { supergraph, query, result } = createExampleSetup(__dirname);

it.todo('executes the query', async () => {
const supergraphPath = await supergraph();
const { port } = await service('nestjs', {
args: [`--supergraph=${supergraphPath}`],
});
const hostname = await getLocalhost(port);
const response = await fetch(`${hostname}:${port}/graphql`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
query,
}),
});
if (!response.ok) {
throw new Error(`HTTP error: ${response.status}: ${await response.text()}`);
}
const received = await response.json();
expect(received).toEqual(result);
});
15 changes: 15 additions & 0 deletions e2e/nestjs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "@e2e/nestjs",
"version": "0.0.1",
"private": true,
"dependencies": {
"@graphql-hive/nestjs": "workspace:^",
"@nestjs/common": "^11.0.10",
"@nestjs/core": "^11.0.10",
"@nestjs/graphql": "^13.0.3",
"@nestjs/platform-express": "^11.0.10",
"graphql": "^16.10.0",
"reflect-metadata": "^0.2.2",
"rxjs": "^7.8.1"
}
}
20 changes: 20 additions & 0 deletions e2e/nestjs/services/nestjs/app.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import {
HiveGatewayDriver,
HiveGatewayDriverConfig,
} from '@graphql-hive/nestjs';
import { Opts } from '@internal/testing';
import { Module } from '@nestjs/common';
import { GraphQLModule } from '@nestjs/graphql';

const opts = Opts(process.argv);
const supergraph = opts.get('supergraph', true);

@Module({
imports: [
GraphQLModule.forRoot<HiveGatewayDriverConfig>({
driver: HiveGatewayDriver,
supergraph,
}),
],
})
export class AppModule {}
16 changes: 16 additions & 0 deletions e2e/nestjs/services/nestjs/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Opts } from '@internal/testing';
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';

const opts = Opts(process.argv);
const port = opts.getServicePort('nestjs', true);

async function main() {
const app = await NestFactory.create(AppModule);
await app.listen(port);
}

main().catch((err) => {
console.error(err);
process.exit(1);
});
2 changes: 1 addition & 1 deletion jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const rootDir = __dirname;
const tsconfigPath = resolve(rootDir, 'tsconfig.json');
const tsconfigContents = readFileSync(tsconfigPath, 'utf8');
const tsconfig = JSON5.parse(tsconfigContents);
const ESM_PACKAGES = ['graphql-federation-gateway-audit'];
const ESM_PACKAGES = ['graphql-federation-gateway-audit', 'parse-duration'];

export default {
testEnvironment: 'node',
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@
},
"devDependencies": {
"@babel/core": "7.26.9",
"@babel/plugin-proposal-decorators": "7.25.9",
"@babel/plugin-proposal-explicit-resource-management": "7.25.9",
"@babel/plugin-transform-class-properties": "7.25.9",
"@babel/plugin-transform-class-static-block": "7.26.0",
"@babel/preset-env": "7.26.9",
"@babel/preset-typescript": "7.26.0",
"@changesets/changelog-github": "^0.5.0",
Expand Down
8 changes: 8 additions & 0 deletions packages/gateway/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ export async function loadConfig<
return importedConfig || {};
}

/**
* This is an internal API and might have breaking changes in the future.
* So use it with caution.
*/
export async function getBuiltinPluginsFromConfig(
config: GatewayCLIBuiltinPluginConfig,
ctx: {
Expand Down Expand Up @@ -157,6 +161,10 @@ export async function getBuiltinPluginsFromConfig(
return plugins;
}

/**
* This is an internal API and might have breaking changes in the future.
* So use it with caution.
*/
export async function getCacheInstanceFromConfig(
config: GatewayCLIBuiltinPluginConfig,
ctx: { logger: Logger; pubsub: MeshPubSub; cwd: string },
Expand Down
4 changes: 4 additions & 0 deletions packages/gateway/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,7 @@ export {
type HTTPTransportOptions,
default as HTTPTransport,
} from '@graphql-mesh/transport-http';
export {
getCacheInstanceFromConfig,
getBuiltinPluginsFromConfig,
} from './config';
Comment on lines +29 to +32
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Verify the impact of exposing internal APIs.

The newly exported functions are marked as internal APIs with potential breaking changes. Ensure that consumers of these APIs are aware of the stability implications.

Consider one of the following approaches:

  1. Document the experimental status in the package's README
  2. Add a stability index (similar to Node.js) to clearly indicate the API's stability level

68 changes: 68 additions & 0 deletions packages/nestjs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"name": "@graphql-hive/nestjs",
"version": "0.0.0",
"type": "module",
"repository": {
"type": "git",
"url": "git+https://github.com/graphql-hive/gateway.git",
"directory": "packages/nestjs"
},
"homepage": "https://the-guild.dev/graphql/hive/docs/gateway",
"author": {
"email": "[email protected]",
"name": "The Guild",
"url": "https://the-guild.dev"
},
"license": "MIT",
"engines": {
"node": ">=18.0.0"
},
"main": "./dist/index.js",
"exports": {
".": {
"require": {
"types": "./dist/index.d.cts",
"default": "./dist/index.cjs"
},
"import": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
},
"./package.json": "./package.json"
},
"types": "./dist/index.d.ts",
"files": [
"dist"
],
"scripts": {
"build": "pkgroll --clean-dist",
"prepack": "yarn build"
},
"peerDependencies": {
"@nestjs/common": "^10 || ^11",
"@nestjs/graphql": "^12 || ^13",
"graphql": "^15.9.0 || ^16.9.0"
},
"dependencies": {
"@graphql-hive/gateway": "workspace:^",
"@graphql-mesh/types": "^0.103.18",
"@graphql-tools/utils": "^10.8.1",
"@whatwg-node/promise-helpers": "^1.0.0",
"tslib": "^2.8.1"
},
"devDependencies": {
"@nestjs/common": "11.0.10",
"@nestjs/core": "11.0.10",
"@nestjs/graphql": "13.0.3",
"@nestjs/testing": "11.0.11",
"@types/supertest": "6.0.2",
"fastify": "5.2.1",
"graphql": "^16.9.0",
"pkgroll": "2.10.0",
"reflect-metadata": "0.2.2",
"rxjs": "7.8.1",
"supertest": "7.0.0"
},
"sideEffects": false
}
Loading
Loading