type-graphql: Cannot read property 'type' of undefined on building with union result type
I have an error when working with union result type.
Here is working demo
Uncomment getUserWithUnion
method in resolver.ts
to reproduce the problem.
TypeError: Cannot read property 'type' of undefined
at /home/maxim/workspace/demo/node_modules/type-graphql/dist/schema/schema-generator.js:66:101
at Array.map (<anonymous>)
at types (/home/maxim/workspace/demo/node_modules/type-graphql/dist/schema/schema-generator.js:66:22)
at resolveThunk (/home/maxim/workspace/demo/node_modules/graphql/type/definition.js:438:40)
at defineTypes (/home/maxim/workspace/demo/node_modules/graphql/type/definition.js:837:15)
at GraphQLUnionType.getTypes (/home/maxim/workspace/demo/node_modules/graphql/type/definition.js:806:26)
at typeMapReducer (/home/maxim/workspace/demo/node_modules/graphql/type/schema.js:272:28)
at typeMapReducer (/home/maxim/workspace/demo/node_modules/graphql/type/schema.js:286:20)
at Array.reduce (<anonymous>)
at new GraphQLSchema (/home/maxim/workspace/demo/node_modules/graphql/type/schema.js:145:28)
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 16 (6 by maintainers)
https://typegraphql.ml/docs/unions.html
As stated per GraphQL specification, union type can consist only object types: http://graphql.org/learn/schema/#union-types