Graphql: Generated schemas for multiple instances are same

Created on 7 Apr 2019  Â·  10Comments  Â·  Source: nestjs/graphql

I'm submitting a...


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior


I'm using multiple GraphQL instances with code first pattern.

Example:

GraphQLModule.forRoot({
      path: '/graphql',
      include: [CatModule],
      autoSchemaFile: 'graphql/schema.graphql',
    }),
    GraphQLModule.forRoot({
      path: '/admin-graphql',
      include: [CatAdminModule],
      autoSchemaFile: 'graphql/admin-schema.graphql',
    }),

It will generate same schemas, include all resolvers and types in project.

Expected behavior

Generated schemas include only declared modules.

Environment


Nest version: 6.0.5


For Tooling issues:
- Node version: v11.11.0
- Platform:  Mac

Others:

blocked

Most helpful comment

@bukhalo don't use type-graphql, author doesn't accept any contribution and wants money for work ¯_(ツ)_/¯

All 10 comments

This cannot be fixed until the metadata collection logic has been rewritten in type-graphql

https://github.com/19majkel94/type-graphql/issues/183

Facing the same Issue.

@Fyzu maybe you have a temporary workaround until the type-graphql author solves the problem?

@bukhalo don't use type-graphql, author doesn't accept any contribution and wants money for work ¯_(ツ)_/¯

author doesn't accept any contribution

Only 37 merged PRs ¯_(ツ)_/¯
https://github.com/MichalLytek/type-graphql/pulls?utf8=✓&q=is%3Apr+sort%3Aupdated-desc+is%3Amerged+label%3A"Community++%3Afamily_man_girl%3A"+

wants money for work

How the open source developers dare to want money for maintaining the open source project that many companies uses! Scandal! 🙈

As I said in that issue, I can't accept a PR with a complete rewrite of the core done by an external contributor. And as I'm preparing a complete rewrite with monorepo, I won't double my work to rewrite the pipeline now and then rewrite again e.g. to add proper plugins support.

For now you can use your fork and publish it on npm as @fyzu/type-graphql or just wait â„¢ for the vNext release.

Only 37 merged PRs ¯_(ツ)_/¯

25 of them are about documentation
https://github.com/MichalLytek/type-graphql/pulls?q=is%3Apr+sort%3Aupdated-desc+is%3Amerged+label%3A%22Community++%3Afamily_man_girl%3A%22+label%3A%22Documentation+%3Abook%3A%22

How the open source developers dare to want money for maintaining the open source project that many companies uses! Scandal! 🙈

what a problem, to let community contribute to project? many devs wanna use and move forward projects like that, without "donate money", only "donate" their own time

25 of them are about documentation

So 37-25 = 12 PR of features -> "doesn't accept any contribution"? 😄

what a problem, to let community contribute to project?

There are 6 issues that are open for help but nobody wants to make a PR 😞
https://github.com/MichalLytek/type-graphql/issues?q=is%3Aopen+is%3Aissue+label%3A"Help+Wanted+%3Asos%3A"

I will reverse your question:
What a problem to create your own fork and only "donate" your own time? If you have time and better ideas, you can even name it better-type-graphql, provide integration with Nest and use it!

If you think that TypeGraphQL is overrated, there are plenty similar project that you can contribute too if you don't want your own OSS project:
https://github.com/ts-graphql/ts-graphql
https://github.com/RaccoonCH/Rakkit
https://github.com/prismake/typegql

maybe you have a temporary workaround until the type-graphql author solves the problem?

@bukhalo It's tracked by #110 - you need to have imports separation in your app and run two node processes:
https://github.com/MichalLytek/type-graphql/issues/110#issuecomment-404023653

its work for me, just add validation rule to GqlModuleOptions:

resolverValidationOptions: {
  allowResolversNotInSchema: true,
}

full example:

const GRAPHQL_OPTIONS: GqlModuleOptions = {
  debug: true,
  playground: true,
  tracing: true,
  introspection: true,
  installSubscriptionHandlers: true,
  resolverValidationOptions: {
    allowResolversNotInSchema: true,
  },
  context: ({ req }) => ({ req }),
};
@Module({
  imports: [
    GraphQLModule.forRootAsync({
      imports: [ConfigModule, ResolverModule1, ResolverModule2],
      useFactory: async (configService: ConfigService) => ({
        path: configService.find('GRAPHQL_ADMIN_PATH') || GRAPHQL_ADMIN_PATH,
        typePaths: [GRAPHQL_TYPE_ADMIN_PATH],
        ...GRAPHQL_OPTIONS,
      }),
      inject: [ConfigService],
    }),
    GraphQLModule.forRootAsync({
      imports: [ConfigModule, ResolverModule3, ResolverModule4],
      useFactory: async (configService: ConfigService) => ({
        path: configService.find('GRAPHQL_PATH') || GRAPHQL_PATH,
        typePaths: [GRAPHQL_TYPE_PATH],
        ...GRAPHQL_OPTIONS,
      }),
      inject: [ConfigService],
    }),
    TypeORMModule, 
  ],
})
export class AppModule {}
Was this page helpful?
0 / 5 - 0 ratings