-
-
Notifications
You must be signed in to change notification settings - Fork 568
Description
I have a large number of types (130+) in my code base, and I'm worried about the overhead of building them all for every little request. I followed the advice in your documentation, and made sure that my objects return callbacks for their field
properties, and I provided a typeLoader
callback when instantiating my Schema
. I understand the general concept, but I must be missing a piece, because at least some types are still being constructed even though they are not referenced in any way by the query being made.
After analyzing the sample here it's not clear to me where the savings are. Imagine if MyTypeA
had a list of 100 fields on it instead of 1; wouldn't 100 calls to $this->get(<fieldName>)
trigger as soon as its fields
callback resolves? Or is there some magic I'm missing?
I guess I was expecting something more like this:
private function MyTypeA()
{
return new ObjectType([
'name' => 'MyTypeA',
'fields' => function() {
return [
'b' => ['type' => 'MyTypeB'] // use a string (or possibly a callable) here, rather than resolve the type on the spot
];
}
]);
}
...with the idea being that I use the name of the type in my field definition rather than a reference to the field itself, and then at runtime it would use the name to look up the type when needed.
I'm pretty sure this is just a matter of me being dumb and not getting something fundamental, so I guess my real question here is whether you think the lazy loading documentation could be improved a bit, or perhaps incorporated into the samples. If you can help me get my questions sorted out I'd be happy to help with either.
Thanks for the wonderful library!