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
-
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(
getContact
method) has no problem accessing the source typeCustomer
and can extract the id out of it. But if I go one level deeper, the address data fetcher (getAddress
method) 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
ContactInternal
which contains thecustomerId
to 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