You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
I am unable to create a resolver for an interface type. I want to create a resolver with a field resolver for an interface type but I am getting a crash at this line.
The reason why is that the resolver is defined in this.interfaceTypes instead of this.classTypes and so the find on the line before is null.
It doesn't crash if I change the previous line to be:
constobjectType=this.objectTypes.find(o=>o.target===t)||this.interfaceTypes.find(o=>o.target===t);// <-- I added this
Then it successfully finds the objectType. I'm not sure if more is needed beyond this point or if that's all. Also, this should probably throw a helpful error if objectType is undefined after this rather than crashing with a null reference exception.
@InterfaceType()exportclassCharacter{
@Field()publicname: string}
@Resolver(of=>Character)// <-- this crashes my appexportclassCharacterResolver{constructor(privatereadonlycharacters: CharacterService){}
@ResolveProperty(type=>String)publicasyncname(@Root()character: Character){returnthis.charcaters.resolveName(character)}}
Expected behavior
I expect there to be no crashing.
I expect the resolver class to resolve fields for types of that interface.
For example if I am returning an interface Character { name } and I query without fragments it should resolve to this function unless there is a more specific concrete type resolver declared:
queryCharacterNames {
characters {
name # <-- should resolve to my CharacterResolver.name method
}
}
Logs
TypeError: Cannot read property 'fields' of undefined
at /d/code/livemenu-api/apps/api/node_modules/type-graphql/dist/metadata/metadata-storage.js:134:52
at Array.forEach (<anonymous>)
at MetadataStorage.buildFieldResolverMetadata (/d/code/livemenu-api/apps/api/node_modules/type-graphql/dist/metadata/metadata-storage.js:122:21)
at MetadataStorage.build (/d/code/livemenu-api/apps/api/node_modules/type-graphql/dist/metadata/metadata-storage.js:77:14)
at Function.generateFromMetadataSync (/d/code/livemenu-api/apps/api/node_modules/type-graphql/dist/schema/schema-generator.js:29:51)
at Function.<anonymous> (/d/code/livemenu-api/apps/api/node_modules/type-graphql/dist/schema/schema-generator.js:16:33)
at Generator.next (<anonymous>)
at /d/code/livemenu-api/apps/api/node_modules/type-graphql/node_modules/tslib/tslib.js:110:75
at new Promise (<anonymous>)
at Object.__awaiter (/d/code/livemenu-api/apps/api/node_modules/type-graphql/node_modules/tslib/tslib.js:106:16)
at Function.generateFromMetadata (/d/code/livemenu-api/apps/api/node_modules/type-graphql/dist/schema/schema-generator.js:15:24)
at /d/code/livemenu-api/apps/api/node_modules/type-graphql/dist/utils/buildSchema.js:11:65
at Generator.next (<anonymous>)
at /d/code/livemenu-api/apps/api/node_modules/type-graphql/node_modules/tslib/tslib.js:110:75
at new Promise (<anonymous>)
at Object.__awaiter (/d/code/livemenu-api/apps/api/node_modules/type-graphql/node_modules/tslib/tslib.js:106:16)
Enviorment (please complete the following information):
OS: Ubuntu (windows wsl)
Node 12.8.0
Package version 0.17.5
TypeScript version 3.5.2
Additional context
I am using this via @nestjs
The text was updated successfully, but these errors were encountered:
Kinda duplicate of #260, related to #261 - @InterfaceType in TypeGraphQL was not designed as an abstract object type an has no arguments and resolvers support 😞
I'm not sure if more is needed beyond this point or if that's all.
It's not enough, resolvers are not created at all in graphql-js.
Describe the bug
I am unable to create a resolver for an interface type. I want to create a resolver with a field resolver for an interface type but I am getting a crash at this line.
The reason why is that the resolver is defined in
this.interfaceTypes
instead ofthis.classTypes
and so the find on the line before is null.It doesn't crash if I change the previous line to be:
Then it successfully finds the objectType. I'm not sure if more is needed beyond this point or if that's all. Also, this should probably throw a helpful error if objectType is undefined after this rather than crashing with a null reference exception.
To Reproduce
@nestjs
Support for property resolvers for interface types nestjs/graphql#429Expected behavior
For example if I am returning an
interface Character { name }
and I query without fragments it should resolve to this function unless there is a more specific concrete type resolver declared:Logs
Enviorment (please complete the following information):
Additional context
I am using this via
@nestjs
The text was updated successfully, but these errors were encountered: