Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

discover graphql mutations, queries, subscriptions? #692

Open
apopapazisis opened this issue Feb 9, 2024 · 2 comments
Open

discover graphql mutations, queries, subscriptions? #692

apopapazisis opened this issue Feb 9, 2024 · 2 comments

Comments

@apopapazisis
Copy link

apopapazisis commented Feb 9, 2024

is it possible to discover graphql mutations, queries, subscriptions?

@apopapazisis apopapazisis changed the title discover graphql mutations, queries, ubscriptions? discover graphql mutations, queries, subscriptions? Feb 9, 2024
@WonderPanda
Copy link
Collaborator

Yes, it should be possible. You will just have to refer to the NestJS code to determine what metadata gets attached when those decorators are used and then you can use the Discovery package to look them up

@apopapazisis
Copy link
Author

@WonderPanda
I try to do this

import { NestFactory } from '@nestjs/core';
import { Module } from '@nestjs/common';
import { DiscoveryModule, DiscoveryService } from '@golevelup/nestjs-discovery';
import { GraphQLSchemaBuilderModule } from '@nestjs/graphql';

@Module({
  imports: [
    DiscoveryModule,
    GraphQLSchemaBuilderModule
  ]
})

class CustomModule {}

const main = async () => {
  const app = await NestFactory.create(CustomModule);
  await app.init();

  const discoveryService = app.get(DiscoveryService);
  const resolvers = await discoveryService.providersWithMetaAtKey('graphql:resolver');

  console.log(resolvers)
};
main();

which returns an empty array, I am not sure that the code I have is 100% correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants