How do I support a query with aliases returning different data? #324
Unanswered
nick-stephen
asked this question in
Q&A
Replies: 1 comment
-
I ended up implementing this in my codebase via the equivalent of
I then added a DataFetcher for the 'reviews' type which fetches the review from the localContext that is passed in through the DataFetchingEnvironment. ... my implementation dealt with a recursive LocalContext structure for the nested graph query, and had about a dozen parameterizable fields that were dealt with like this, so the actual IdentityHashMap type I used was , but the explanation remains the same. To avoid passing this around through the recursive methods that evaluate the query, I used a ThreadLocal. Hope this might help someone. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Please can someone explain if/how DGS supports graphql aliases, especially for fields with different parameters.
Here is an example of the kind of query I'd like to be able to ask using the
dgs-examples-java
codebase:Note that the example implementation specifies but ignores the
minScore
parameter today, but the returned list fromaverage
andbest
should be different.I'd like to be able to retrieve different lists for
average
andbest
by passing in the arguments to theDataLoader
, without the need for post-filtering in theDataFetcher
.Even better, I'm actually implementing using pre-loading, and it seems impossible to naively implement aliases like this using normal pre-loading populating each field including child fields, since there is only a single field to populate in DGS generated entities, so it'd appear essential to use the
localContext
plus multipleDataFetcher
implementations, an update example doing this would be fabulous...Many thx!
Beta Was this translation helpful? Give feedback.
All reactions