Graphql: Unable to import types defined in compiled npm modules

Created on 14 Apr 2020  路  4Comments  路  Source: nestjs/graphql

I'm submitting a...


[x] 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


When exporting an @ObjectType() class, compiling and publishing to my npm repository I'm no longer able to import that class and use it as a type in my resolver.

When the schema tries to generate the following error is thrown (error from the reproduction repository)

(node:20308) UnhandledPromiseRejectionWarning: Error: Cannot determine a GraphQL output type for the "failedQuery". Make sure your class is decorated with an appropriate decorator.
    at OutputTypeFactory.create (~/examples/nest-graph-example/service1/node_modules/@nestjs/graphql/dist/schema-builder/factories/output-type.factory.js:18:23)
    at handlers.filter.forEach.handler (~/examples/nest-graph-example/service1/node_modules/@nestjs/graphql/dist/schema-builder/factories/root-type.factory.js:35:49)
    at Array.forEach (<anonymous>)
    at RootTypeFactory.generateFields (~/examples/nest-graph-example/service1/node_modules/@nestjs/graphql/dist/schema-builder/factories/root-type.factory.js:33:14)
    at fieldsFactory (~/examples/nest-graph-example/service1/node_modules/@nestjs/graphql/dist/schema-builder/factories/root-type.factory.js:17:99)
    at RootTypeFactory.create (~/examples/nest-graph-example/service1/node_modules/@nestjs/graphql/dist/schema-builder/factories/root-type.factory.js:26:21)
    at QueryTypeFactory.create (~/examples/nest-graph-example/service1/node_modules/@nestjs/graphql/dist/schema-builder/factories/query-type.factory.js:14:37)
    at GraphQLSchemaFactory.<anonymous> (~/examples/nest-graph-example/service1/node_modules/@nestjs/graphql/dist/schema-builder/graphql-schema.factory.js:30:46)
    at Generator.next (<anonymous>)
    at ~/examples/nest-graph-example/service1/node_modules/tslib/tslib.js:113:75
(node:20308) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:20308) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Expected behavior


As with v6 when using type-graphql, the class should be imported and the type should be added to the generated schema.

Minimal reproduction of the problem with instructions


https://github.com/joseym/nestjs-gql-export-issue

Environment

@nestjs/[email protected]
@nestjs/[email protected]
@nestjs/[email protected]
@nestjs/[email protected]

For Tooling issues:
- Node version: `v10.15.3`
- Platform:  `Mac v10.15.5`
needs clarification

Most helpful comment

Can you test with @nestjs/graphql@next (next tag) please?

All 4 comments

Can you test with @nestjs/graphql@next (next tag) please?

@kamilmysliwiec I'm thrilled to say that the next version seems to resolve my problem!

Awesome! Fixed in 7.3.1 :)

Thanks @kamilmysliwiec!

Was this page helpful?
0 / 5 - 0 ratings