nexus
nexus copied to clipboard
Interface resolveType is not optional
It should be possible to define:
export const UserError = interfaceType({
definition(t) {
t.string('id')
},
name: 'UserError',
})
But I get an error:
Argument of type '{ definition(t: InterfaceDefinitionBlock<"UserError">): void; name: "UserError"; }' is not assignable to parameter of type 'NexusInterfaceTypeConfig<"UserError">'.
Property 'resolveType' is missing in type '{ definition(t: InterfaceDefinitionBlock<"UserError">): void; name: "UserError"; }' but required in type '{ resolveType: AbstractTypeResolver<"UserError">; }'
It should be possible to define:
Are you using https://nexusjs.org/docs/guides/abstract-types#centralized-strategy-resolvetype?
Then this is expected I think.
I mean the definition is:
Optionally provide a custom type resolver function. If one is not provided, the default implementation will first look for __typename, then fallback to calling isTypeOf on each implementing Object type.
I want to use the default implementation in this case :)
Yeah something seems fishy here.
Optionally provide a custom type resolver function. If one is not provided, the default implementation will first look for __typename, then fallback to calling isTypeOf on each implementing Object type.
Yeah I think this doc might have been from before we switched resolveType
to be the default.
At the moment, I believe resolveType
is required if __typename
isn't explicitly defined on all sourceType
for members of the interface.
I feel like the local abstract settings would be really helpful here. @jasonkuhrt have you given much thought on how difficult you think this might be?
I feel like the local abstract settings would be really helpful here. @jasonkuhrt have you given much thought on how difficult you think this might be?
No thoughts up to now! And no sense on level-of-interest others have for it. Great to hear you think it would be useful. Have you heard any input from others about it too?
I'm getting this error now and wondering what the correct fix for it is. Does anyone have one?
Well, I seem to have found it pretty quickly after all. Adding this to the config object of makeSchema()
features: {
abstractTypeStrategies: {
resolveType: false
}
}