Lazy load attributes of types #2066
-
Hi everybody! Maybe this has already been solved but I couldn't find anything about it.. In my schema I have a very deep graph which is loaded in a lazy loading style on the service side. Now my question is, is it possible to provide such functionality via the field itself? I guess there is always the possibility to do a lookup in the selected_fields but I guess this is not a "clean" way to do so. A minimal example of my use case would be:
and for a getBookStores query which return [BookStore!]! only the name would be needed
I'd be happy to share ideas or possible solutions:-) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @thomaskoller, you have two options, one is, as you said, checking the fields that have been queried, for example here: https://play.strawberry.rocks/?gist=2aa96867347be75beb2435d0c8d1c304 the other options is to use per field resolvers, like so: https://play.strawberry.rocks/?gist=e01d4c9271d8bc780df7649fe42868fd Also take a look at this blog post, which has some great ideas: https://andrewingram.net/posts/optimising-your-graphql-request-waterfalls/ |
Beta Was this translation helpful? Give feedback.
Hi @thomaskoller, you have two options, one is, as you said, checking the fields that have been queried, for example here: https://play.strawberry.rocks/?gist=2aa96867347be75beb2435d0c8d1c304
the other options is to use per field resolvers, like so:
https://play.strawberry.rocks/?gist=e01d4c9271d8bc780df7649fe42868fd
Also take a look at this blog post, which has some great ideas: https://andrewingram.net/posts/optimising-your-graphql-request-waterfalls/