Skip to content

Commit e369a06

Browse files
committed
..
1 parent 7b1b87f commit e369a06

File tree

3 files changed

+188
-12
lines changed

3 files changed

+188
-12
lines changed

packages/nestjs/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"@graphql-hive/gateway": "workspace:^",
4949
"@graphql-mesh/types": "^0.103.18",
5050
"@graphql-tools/utils": "^10.8.1",
51+
"@whatwg-node/promise-helpers": "^1.0.0",
5152
"tslib": "^2.8.1"
5253
},
5354
"devDependencies": {

packages/nestjs/src/index.ts

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import {
1616
import {
1717
asArray,
1818
getResolversFromSchema,
19-
mapMaybePromise,
2019
type IResolvers,
2120
type TypeSource,
2221
} from '@graphql-tools/utils';
@@ -29,6 +28,7 @@ import {
2928
type SubscriptionConfig,
3029
} from '@nestjs/graphql';
3130
import type { FastifyReply, FastifyRequest } from 'fastify';
31+
import { handleMaybePromise } from '@whatwg-node/promise-helpers';
3232

3333
export type HiveGatewayDriverConfig<
3434
TContext extends Record<string, any> = Record<string, any>,
@@ -71,16 +71,7 @@ export class HiveGatewayDriver<
7171
const resolversFromSchema = getResolversFromSchema(schema);
7272
additionalResolvers.push(resolversFromSchema);
7373
}
74-
const contextPlugin: GatewayPlugin = {
75-
// @ts-expect-error - MaybePromise and PromiseOrValue are incompatible
76-
onContextBuilding: ({ context, extendContext }) =>
77-
mapMaybePromise(
78-
typeof options.context === 'function'
79-
? options.context(context)
80-
: options.context,
81-
(newContext) => extendContext(newContext),
82-
),
83-
};
74+
;
8475
const logger = new NestJSLoggerAdapter(
8576
'Hive Gateway',
8677
{},
@@ -112,7 +103,19 @@ export class HiveGatewayDriver<
112103
? {
113104
plugins: (ctx) => {
114105
const existingPlugins = options.plugins?.(ctx) || [];
115-
return [...builtinPlugins, ...existingPlugins, contextPlugin];
106+
if (options.context) {
107+
const contextPlugin: GatewayPlugin = {
108+
onContextBuilding: ({ context, extendContext }) =>
109+
handleMaybePromise(
110+
() => typeof options.context === 'function'
111+
? options.context(context)
112+
: options.context,
113+
extendContext,
114+
),
115+
}
116+
existingPlugins.push(contextPlugin);
117+
}
118+
return [...builtinPlugins, ...existingPlugins];
116119
},
117120
}
118121
: {}),

yarn.lock

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3479,6 +3479,7 @@ __metadata:
34793479
"@nestjs/common": "npm:11.0.9"
34803480
"@nestjs/core": "npm:11.0.9"
34813481
"@nestjs/graphql": "npm:13.0.2"
3482+
"@whatwg-node/promise-helpers": "npm:^1.0.0"
34823483
fastify: "npm:5.2.1"
34833484
graphql: "npm:^16.9.0"
34843485
pkgroll: "npm:2.10.0"
@@ -6707,6 +6708,138 @@ __metadata:
67076708
languageName: node
67086709
linkType: hard
67096710

6711+
"@swc/core-darwin-arm64@npm:1.11.1":
6712+
version: 1.11.1
6713+
resolution: "@swc/core-darwin-arm64@npm:1.11.1"
6714+
conditions: os=darwin & cpu=arm64
6715+
languageName: node
6716+
linkType: hard
6717+
6718+
"@swc/core-darwin-x64@npm:1.11.1":
6719+
version: 1.11.1
6720+
resolution: "@swc/core-darwin-x64@npm:1.11.1"
6721+
conditions: os=darwin & cpu=x64
6722+
languageName: node
6723+
linkType: hard
6724+
6725+
"@swc/core-linux-arm-gnueabihf@npm:1.11.1":
6726+
version: 1.11.1
6727+
resolution: "@swc/core-linux-arm-gnueabihf@npm:1.11.1"
6728+
conditions: os=linux & cpu=arm
6729+
languageName: node
6730+
linkType: hard
6731+
6732+
"@swc/core-linux-arm64-gnu@npm:1.11.1":
6733+
version: 1.11.1
6734+
resolution: "@swc/core-linux-arm64-gnu@npm:1.11.1"
6735+
conditions: os=linux & cpu=arm64 & libc=glibc
6736+
languageName: node
6737+
linkType: hard
6738+
6739+
"@swc/core-linux-arm64-musl@npm:1.11.1":
6740+
version: 1.11.1
6741+
resolution: "@swc/core-linux-arm64-musl@npm:1.11.1"
6742+
conditions: os=linux & cpu=arm64 & libc=musl
6743+
languageName: node
6744+
linkType: hard
6745+
6746+
"@swc/core-linux-x64-gnu@npm:1.11.1":
6747+
version: 1.11.1
6748+
resolution: "@swc/core-linux-x64-gnu@npm:1.11.1"
6749+
conditions: os=linux & cpu=x64 & libc=glibc
6750+
languageName: node
6751+
linkType: hard
6752+
6753+
"@swc/core-linux-x64-musl@npm:1.11.1":
6754+
version: 1.11.1
6755+
resolution: "@swc/core-linux-x64-musl@npm:1.11.1"
6756+
conditions: os=linux & cpu=x64 & libc=musl
6757+
languageName: node
6758+
linkType: hard
6759+
6760+
"@swc/core-win32-arm64-msvc@npm:1.11.1":
6761+
version: 1.11.1
6762+
resolution: "@swc/core-win32-arm64-msvc@npm:1.11.1"
6763+
conditions: os=win32 & cpu=arm64
6764+
languageName: node
6765+
linkType: hard
6766+
6767+
"@swc/core-win32-ia32-msvc@npm:1.11.1":
6768+
version: 1.11.1
6769+
resolution: "@swc/core-win32-ia32-msvc@npm:1.11.1"
6770+
conditions: os=win32 & cpu=ia32
6771+
languageName: node
6772+
linkType: hard
6773+
6774+
"@swc/core-win32-x64-msvc@npm:1.11.1":
6775+
version: 1.11.1
6776+
resolution: "@swc/core-win32-x64-msvc@npm:1.11.1"
6777+
conditions: os=win32 & cpu=x64
6778+
languageName: node
6779+
linkType: hard
6780+
6781+
"@swc/core@npm:1.11.1":
6782+
version: 1.11.1
6783+
resolution: "@swc/core@npm:1.11.1"
6784+
dependencies:
6785+
"@swc/core-darwin-arm64": "npm:1.11.1"
6786+
"@swc/core-darwin-x64": "npm:1.11.1"
6787+
"@swc/core-linux-arm-gnueabihf": "npm:1.11.1"
6788+
"@swc/core-linux-arm64-gnu": "npm:1.11.1"
6789+
"@swc/core-linux-arm64-musl": "npm:1.11.1"
6790+
"@swc/core-linux-x64-gnu": "npm:1.11.1"
6791+
"@swc/core-linux-x64-musl": "npm:1.11.1"
6792+
"@swc/core-win32-arm64-msvc": "npm:1.11.1"
6793+
"@swc/core-win32-ia32-msvc": "npm:1.11.1"
6794+
"@swc/core-win32-x64-msvc": "npm:1.11.1"
6795+
"@swc/counter": "npm:^0.1.3"
6796+
"@swc/types": "npm:^0.1.18"
6797+
peerDependencies:
6798+
"@swc/helpers": "*"
6799+
dependenciesMeta:
6800+
"@swc/core-darwin-arm64":
6801+
optional: true
6802+
"@swc/core-darwin-x64":
6803+
optional: true
6804+
"@swc/core-linux-arm-gnueabihf":
6805+
optional: true
6806+
"@swc/core-linux-arm64-gnu":
6807+
optional: true
6808+
"@swc/core-linux-arm64-musl":
6809+
optional: true
6810+
"@swc/core-linux-x64-gnu":
6811+
optional: true
6812+
"@swc/core-linux-x64-musl":
6813+
optional: true
6814+
"@swc/core-win32-arm64-msvc":
6815+
optional: true
6816+
"@swc/core-win32-ia32-msvc":
6817+
optional: true
6818+
"@swc/core-win32-x64-msvc":
6819+
optional: true
6820+
peerDependenciesMeta:
6821+
"@swc/helpers":
6822+
optional: true
6823+
checksum: 10c0/ed6820ac4efba1d77956eb17112a910461d4cfce484babb79d2fc9a79a508d826f9790a9855e2af8598c335b9c26c88447d05e05d260c4fa3a5f6e3e18f4758b
6824+
languageName: node
6825+
linkType: hard
6826+
6827+
"@swc/counter@npm:^0.1.3":
6828+
version: 0.1.3
6829+
resolution: "@swc/counter@npm:0.1.3"
6830+
checksum: 10c0/8424f60f6bf8694cfd2a9bca45845bce29f26105cda8cf19cdb9fd3e78dc6338699e4db77a89ae449260bafa1cc6bec307e81e7fb96dbf7dcfce0eea55151356
6831+
languageName: node
6832+
linkType: hard
6833+
6834+
"@swc/types@npm:^0.1.18":
6835+
version: 0.1.18
6836+
resolution: "@swc/types@npm:0.1.18"
6837+
dependencies:
6838+
"@swc/counter": "npm:^0.1.3"
6839+
checksum: 10c0/0c34ed1670daeb991de87a79c859d68980def32caf02999ef906859d02a2ee13a7f998e84b40022ce970fdceea9f77005e4965038f5139b93035956118aae7ea
6840+
languageName: node
6841+
linkType: hard
6842+
67106843
"@szmarczak/http-timer@npm:^4.0.5":
67116844
version: 4.0.6
67126845
resolution: "@szmarczak/http-timer@npm:4.0.6"
@@ -11639,6 +11772,7 @@ __metadata:
1163911772
"@changesets/changelog-github": "npm:^0.5.0"
1164011773
"@changesets/cli": "patch:@changesets/cli@npm%3A2.27.9#~/.yarn/patches/@changesets-cli-npm-2.27.9-5df61a909e.patch"
1164111774
"@ianvs/prettier-plugin-sort-imports": "npm:^4.3.1"
11775+
"@swc/core": "npm:1.11.1"
1164211776
"@tsconfig/strictest": "npm:^2.0.5"
1164311777
"@types/node": "npm:^22.9.0"
1164411778
"@yarnpkg/cli": "npm:^4.5.3"
@@ -11659,6 +11793,7 @@ __metadata:
1165911793
tsx: "npm:4.19.3"
1166011794
typescript: "npm:^5.6.3"
1166111795
typescript-eslint: "npm:^8.9.0"
11796+
unplugin-swc: "npm:1.5.1"
1166211797
vite: "npm:^6.0.0"
1166311798
vite-tsconfig-paths: "patch:vite-tsconfig-paths@npm%3A5.1.3#~/.yarn/patches/vite-tsconfig-paths-npm-5.1.3-1736ca1872.patch"
1166411799
vitest: "npm:^3.0.1"
@@ -13984,6 +14119,13 @@ __metadata:
1398414119
languageName: node
1398514120
linkType: hard
1398614121

14122+
"load-tsconfig@npm:^0.2.5":
14123+
version: 0.2.5
14124+
resolution: "load-tsconfig@npm:0.2.5"
14125+
checksum: 10c0/bf2823dd26389d3497b6567f07435c5a7a58d9df82e879b0b3892f87d8db26900f84c85bc329ef41c0540c0d6a448d1c23ddc64a80f3ff6838b940f3915a3fcb
14126+
languageName: node
14127+
linkType: hard
14128+
1398714129
"localforage@npm:1.10.0":
1398814130
version: 1.10.0
1398914131
resolution: "localforage@npm:1.10.0"
@@ -18443,6 +18585,29 @@ __metadata:
1844318585
languageName: node
1844418586
linkType: hard
1844518587

18588+
"unplugin-swc@npm:1.5.1":
18589+
version: 1.5.1
18590+
resolution: "unplugin-swc@npm:1.5.1"
18591+
dependencies:
18592+
"@rollup/pluginutils": "npm:^5.1.0"
18593+
load-tsconfig: "npm:^0.2.5"
18594+
unplugin: "npm:^1.11.0"
18595+
peerDependencies:
18596+
"@swc/core": ^1.2.108
18597+
checksum: 10c0/113d9acc4f54a97d1bfc87b4d4c6bf56a99f9e3b392f4c09e15e0abb7dbf2ae4c11679e5a3dd9102f3e62f2c50fdf02883ee51c13e64b7a83b8f2294c47a8071
18598+
languageName: node
18599+
linkType: hard
18600+
18601+
"unplugin@npm:^1.11.0":
18602+
version: 1.16.1
18603+
resolution: "unplugin@npm:1.16.1"
18604+
dependencies:
18605+
acorn: "npm:^8.14.0"
18606+
webpack-virtual-modules: "npm:^0.6.2"
18607+
checksum: 10c0/dd5f8c5727d0135847da73cf03fb199107f1acf458167034886fda3405737dab871ad3926431b4f70e1e82cdac482ac1383cea4019d782a68515c8e3e611b6cc
18608+
languageName: node
18609+
linkType: hard
18610+
1844618611
"update-browserslist-db@npm:^1.1.1":
1844718612
version: 1.1.2
1844818613
resolution: "update-browserslist-db@npm:1.1.2"
@@ -18761,6 +18926,13 @@ __metadata:
1876118926
languageName: node
1876218927
linkType: hard
1876318928

18929+
"webpack-virtual-modules@npm:^0.6.2":
18930+
version: 0.6.2
18931+
resolution: "webpack-virtual-modules@npm:0.6.2"
18932+
checksum: 10c0/5ffbddf0e84bf1562ff86cf6fcf039c74edf09d78358a6904a09bbd4484e8bb6812dc385fe14330b715031892dcd8423f7a88278b57c9f5002c84c2860179add
18933+
languageName: node
18934+
linkType: hard
18935+
1876418936
"whatwg-mimetype@npm:^3.0.0":
1876518937
version: 3.0.0
1876618938
resolution: "whatwg-mimetype@npm:3.0.0"

0 commit comments

Comments
 (0)