Skip to content

How to access the selected fields before field resolution? #397

Answered by vojtapol
benmccann asked this question in Q&A
Discussion options

You must be logged in to vote

The solution you are describing is the field look-ahead strategy and it can be quite powerful for optimizing fetching. In general, I would not recommend it though. One big disadvantage is that you cannot look-ahead into fragments of subtypes because at the time of looking-ahead GraphQL Java still does not know what type will the fragment resolve into.

To avoid over-fetching I would instead recommend fetching just the minimal "skeleton" objects and resolving all additional fields using methods in GraphQLResolver<MyType>. If you then combine it with the GraphQL Java DataLoader concept you will have a very flexible and fast architecture with little to no overfetching.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by vojtapol
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #397 on December 21, 2020 15:47.