How to access root DgsDataFetchingEnvironment.getSource() from a deep nested data fetcher
#55
Unanswered
driptaroop
asked this question in
Q&A
Replies: 1 comment 4 replies
-
|
We recently added docs that explain the different options for dealing with this: https://netflix.github.io/dgs/advanced/context-passing/ |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I was following the documentation on getting the id from the source of the
DgsDataFetchingEnvironment.This is my graphql schema:
This is my data fetcher body:
As you can see, the contact data fetcher(
getContactmethod) has no problem accessing the source typeCustomerand can extract the id out of it. But if I go one level deeper, the address data fetcher (getAddressmethod) cannot access the root source ofCustomer, but can only access parent level (Contact).Since contact does not have the customer Id, I had to create a
ContactInternalwhich contains thecustomerIdto make it work.Is this the right way to do it? or is there anyway to access the root level source from deep nested fetchers?
Beta Was this translation helpful? Give feedback.
All reactions