Describe the bug
When I try defining a resolveType function on createUnionType, it compiles succesfully but I'm getting this warning:
Type "MyUnionType" is missing a "__resolveType" resolver. Pass false into "resolverValidationOptions.requireResolversForResolveType" to disable this warning.
The type then really isn't working and complains with this:
Abstract type MyUnionType must resolve to an Object type at runtime for field UserType.myUnion (...)
To Reproduce
export const MyUnionType = createUnionType({
name: 'MyUnionType',
types: [PersonType, PlaceType],
resolveType: value => {
if (value instanceof PersonEntity) {
return PersonType;
}
if (value instanceof PlaceEntity) {
return PlaceType;
}
return undefined;
},
});
(I didn't test if the resolveType method itself works properly, but that's unrelated to this issue as it's obviously ignored - definitely doesn't get called).
Expected behavior
This should work and resolve into the proper type at runtime.
Enviorment
Asked in https://github.com/19majkel94/type-graphql/issues/326 already, apparently out of their scope so I suppose it belongs here. It's a new feature in type-graphql but I think it would be nice to have it here.
It should be fixed in the @next version ($ npm i @nestjs/graphql@next). You will also have to update @nestjs/core to 6.2.0 ($ npm i @nestjs/[email protected])
Published as 6.2.0 ($ npm i @nestjs/graphql@latest). You will also have to update @nestjs/core to 6.2.0 ($ npm i @nestjs/core@latest)
@kamilmysliwiec still reproducible, I have latest versions @nestjs/graphql 6.4.3 and type-graphql 0.17.5
can confirm - CustomFieldConfigUnion doesnt work.
in my case the unionMetadata.classTypes is empty and throws error at buildTypesInfo() in schema-generator.js
resolveType for createUnionType still doesn't work. Are there any other solutions?
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
It should be fixed in the @next version (
$ npm i @nestjs/graphql@next). You will also have to update@nestjs/coreto 6.2.0 ($ npm i @nestjs/[email protected])