Sorting a result collection. #1900
Answered
by
paulbakker
melishatrout2
asked this question in
Q&A
-
Let's say I have the following schema:
and the following class:
Both soil and plant data are retrieve by two separate API. Is there a way of sorting the soil list by plant commonName before sending the data back to the client? |
Beta Was this translation helpful? Give feedback.
Answered by
paulbakker
May 2, 2024
Replies: 1 comment
-
I'm not aware of a great way of doing this - the problem is that there isn't really a "callback" to run code after the A workaround is to not have a separate datafetcher for
|
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
melishatrout2
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm not aware of a great way of doing this - the problem is that there isn't really a "callback" to run code after the
plants
field datafetcher completed.A workaround is to not have a separate datafetcher for
plants
, but resolve everything in the "root"searchSoilByIds
datafetcher.getSelectionSet
on theDataFetchingEnvironment
to find out if theplants
field is requested. (see https://netflix.github.io/dgs/advanced/context-passing/#pre-loading)soils
, and in the same method, also loadplants
.