File tree Expand file tree Collapse file tree 8 files changed +813
-33
lines changed Expand file tree Collapse file tree 8 files changed +813
-33
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' @graphql-hive/nestjs ' : patch
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 )
Original file line number Diff line number Diff line change 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 ( '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+ const received = await response . json ( ) ;
25+ expect ( received ) . toEqual ( result ) ;
26+ } ) ;
Original file line number Diff line number Diff line change 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.1" ,
8+ "@nestjs/core" : " ^11.0.9" ,
9+ "@nestjs/graphql" : " ^13.0.2" ,
10+ "@nestjs/platform-express" : " ^11.0.9" ,
11+ "graphql" : " ^16.10.0" ,
12+ "reflect-metadata" : " ^0.2.2" ,
13+ "rxjs" : " ^7.8.1"
14+ }
15+ }
Original file line number Diff line number Diff line change 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 { NestFactory } from '@nestjs/core' ;
8+ import { GraphQLModule } from '@nestjs/graphql' ;
9+
10+ const opts = Opts ( process . argv ) ;
11+ const supergraph = opts . get ( 'supergraph' , true ) ;
12+
13+ @Module ( {
14+ imports : [
15+ GraphQLModule . forRoot < HiveGatewayDriverConfig > ( {
16+ driver : HiveGatewayDriver ,
17+ supergraph,
18+ } ) ,
19+ ] ,
20+ } )
21+ class AppModule { }
22+
23+ const port = opts . getServicePort ( 'nestjs' , true ) ;
24+
25+ async function main ( ) {
26+ const app = await NestFactory . create ( AppModule ) ;
27+ await app . listen ( port ) ;
28+ }
29+
30+ main ( ) . catch ( ( err ) => {
31+ console . error ( err ) ;
32+ process . exit ( 1 ) ;
33+ } ) ;
Original file line number Diff line number Diff line change @@ -691,6 +691,7 @@ export function createTenv(cwd: string): Tenv {
691691 pipeLogs = isDebug ( ) ,
692692 args = [ ] ,
693693 protocol = 'http' ,
694+ env,
694695 } = { } ,
695696 ) {
696697 port ||= await getAvailablePort ( ) ;
@@ -702,6 +703,7 @@ export function createTenv(cwd: string): Tenv {
702703 signal : ctrl . signal ,
703704 stack : leftoverStack ,
704705 replaceStderr : ( str ) => str . replaceAll ( __project , '' ) ,
706+ env,
705707 } ,
706708 'node' ,
707709 '--import' ,
You can’t perform that action at this time.
0 commit comments