-
-
Notifications
You must be signed in to change notification settings - Fork 571
Description
I tried to tune the default resolver recently in my application and change the is_object part to call getter instead of dealing with properties:
} elseif (is_object($source)) {
if ($source instanceof Mode) {
$property = $source->{$fieldName};
} else {
$method = 'get' . ucfirst(Str::camel($fieldName));
$property = $source->$method();
}It's a bit Lararvel specific: laravel models use the attribute approach, but everything else simply expect certain getters. (*)
This however fails short because the default resolver is also used for internal types (which I had no idea about), so for example this tried to call \GraphQL\Type\Definition\FieldDefinition::getName instead of accessing \GraphQL\Type\Definition\FieldDefinition->$name.
Well, bummer :)
I guess changing the default resolver in that way is not what I should do. I came across #452 and it seems I should rather use the approach in #452 (comment) .
Would this be a good use-case for my issue?