__typename is not working properly
JonasBorchelt opened this issue · comments
Hey again,
if you do the following request in the song example:
{
artist(name:"Fazerdaze") {
name
songs{
name
duration
__typename
}
__typename
}
__typename
}
You get:
{
"errors": [
{
"message": "Internal error, failed to determine the __typename.",
"code": "eval error",
"timestamp": "2020-05-05T09:32:12.193248000Z"
}
]
}
It's working on the query root with no problem. But as soon it's on a type, it's not working.
I'll look into it tonight. Is the schema the same as in the songs example?
Agoo uses directives to associate a GraphQL type with a Ruby class. During evaluation fields resolve into Ruby objects Agoo must then determine the type for a given Ruby class. It could be smarter and look at the schema types except when a Union or Interface is used and then there is no choice but to have a map for Ruby class to GraphQL type. Right now Agoo uses that map for all calls to __typename.
To fix your immediate issue, make sure each type has an @ruby()
directive. An example if this is the test directory but here is what the Artist type would start with:
type Artist @ruby(class:"Artist") {
Leave this issue open though and I'll try to get __typename to fallback to the schema if it can.
Perfect! Much thanks for your answer. This helps a lot. Yeah, I was debugging through the code and found the part where it checks if "ruby" is there.
Thank you for your effort.