Closed nicam closed 4 years ago
Hi!
Let me know if you still need this to be possible. If so, can you provide some example on how would this be used?
From what I understand, you want something like the following:
@gql_optimizer.resolver_hints(
model_field=lambda info: 'product',
)
def resolve_product(root, info):
return root.product
But instead of returning 'product'
in the lambda, you want to use info
. Is that right?
actually just beeing able to use a lambda function, instead of a string, for model_field would already be enough :)
As far as I have seen you'd only need to wrap it with _normalize_hint_value
internally
Concretly I'd like to do the following:
@gql_optimizer.resolver_hints(
model_field = lambda info: f'image_{translation.get_language()}',
)
The field name needs to be evaluated in the lambda at runtime since it differs by language so I can prefetch the correct model field
Understood! Yeah, from what I can see it should be a simple change. Let me check what I can do. Please ping me if I don't answer you by Sunday.
Fixed in v0.7.0! (commit 3da91421c6de7c2f96749d706a62f84f8787d742)
Thanks a lot!
Hi There!
Would it be possible to have
model_field
also use_normalize_hint_value
so we could use a lambda function?We have the problem that we need to define the hints at runtime since they are different based on language. Using the annotation does only work with lambdas as they get executed during the request.
Thanks for your help!