Skip to content

Commit 24e033e

Browse files
committed
Migrate fastify Plugin
1 parent dcdf09b commit 24e033e

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/core/graphql/driver.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { DiscoveryService } from '@golevelup/nestjs-discovery';
21
import { Injectable } from '@nestjs/common';
32
import {
43
AbstractGraphQLDriver as AbstractDriver,
@@ -16,6 +15,7 @@ import {
1615
import { AsyncLocalStorage } from 'node:async_hooks';
1716
import type { WebSocket } from 'ws';
1817
import { type GqlContextType } from '~/common';
18+
import { MetadataDiscovery } from '~/core/discovery';
1919
import { HttpAdapter, type IRequest } from '../http';
2020
import { type IResponse } from '../http/types';
2121
import { Plugin } from './plugin.decorator';
@@ -34,7 +34,7 @@ export class Driver extends AbstractDriver<DriverConfig> {
3434
private yoga: YogaServerInstance<ServerContext, {}>;
3535

3636
constructor(
37-
private readonly discovery: DiscoveryService,
37+
private readonly discovery: MetadataDiscovery,
3838
private readonly http: HttpAdapter,
3939
) {
4040
super();
@@ -44,12 +44,10 @@ export class Driver extends AbstractDriver<DriverConfig> {
4444
const fastify = this.http.getInstance();
4545

4646
// Do our plugin discovery / registration
47-
const discoveredPlugins = await this.discovery.providersWithMetaAtKey(
48-
Plugin.KEY,
49-
);
47+
const discoveredPlugins = this.discovery.discover(Plugin).classes<Plugin>();
5048
options.plugins = [
5149
...(options.plugins ?? []),
52-
...new Set(discoveredPlugins.map((cls) => cls.discoveredClass.instance)),
50+
...discoveredPlugins.map((cls) => cls.instance),
5351
];
5452

5553
this.yoga = createYoga({

0 commit comments

Comments
 (0)