neo4j-graphql-js
neo4j-graphql-js copied to clipboard
Change default resolveType to use User defined __resolveType when available
Fixes: #414 Aims to let user-defined resolvers for Interfaces and Queries work.
For example users can define a union like:
union SearchItem = Actor | Movie
And the resolver for this union:
const resolver = {
SearchItem: {
__resolveType(obj) => {
return "TypeName"
}
}
}
@hedonhermdev Hi, have you tested that this and confirmed that it works? I can't replicate.
To explain, if I do the following:
const resolver = {
SearchItem: {
__resolveType(obj) => {
console.log('__resolveType for <SearchItem> called')
return 'TypeName'
}
}
}
And the console.log line never prints.
But, if I do this instead:
const resolver = {
Actor: {
__isTypeOf: () => {
console.log('called __isTypeOf function for <Actor>') // gets printed
return 'Actor';
}
},
Movie: {
__isTypeOf: () => {
console.log('called __isTypeOf function for <Movie>') // gets printed
return 'Movie'
}
},
}
https://github.com/neo4j-graphql/neo4j-graphql-js/issues/608