How can i add support for batch _entities in federation #1488
-
I'm converting a legacy app that was bare bones graphql java to netflix dgs We do some wiring that looks like this
It's kind of similar to the dgs @DgsEntityFetcher, except instead of being a singular entity fetcher, it allows performant batching on the app side to load hundreds of employers with a single db query vs resolving one at a time. I see there is a @DgsDataLoader, but im confused how these work in conjunction. Is a DgsEntityFetcher supposed to somehow call a DgsDataLoader? or how is a DgsDataLoader suposed to be used. And does dgs support the above of being able to efficiently batch the entities fetcher for type Employer? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
You can set up a DgsDataLoader and use that within an data fetcher (or entity fetcher) like this: https://netflix.github.io/dgs/data-loaders/#using-a-data-loader Hope this helps. |
Beta Was this translation helpful? Give feedback.
-
Yes, if Employer is the type that is requested as part of the _entities
query, that looks correct to me.
…On Thu, Apr 20, 2023 at 11:01 AM Saran Sundararajan < ***@***.***> wrote:
@srinivasankavitha <https://github.com/srinivasankavitha> does the above
code look right for allowing batching of entities of the Employer parent
type?
—
Reply to this email directly, view it on GitHub
<#1488 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AJ5JPXODZWUG7GDDKT3ZYDDXCF2XHANCNFSM6AAAAAAXEHDEOM>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
@srinivasankavitha Thanks I got a federated apollo graph gateway running locally via passing in a service list to test out the entities, so a couple issues I noticed. One is that DgsEntityFetcher requires an argument of Map<String, Object> values which is fine. The real issue is the DataFetchingEnvironment dfe doesnt seem to be populating the context.
In my normal queries I can grab context and it populates the variables passed from headers, but when testing the federation its not passing the context through to the entity fetcher.
final Context context = DgsContext.getCustomContext(env);