how can I transfer data from the parent data loader to the child data loader #1711
Replies: 1 comment
-
Let me know if I'm misunderstanding the question, but I'm assuming you have a parent field and a child field, both that use data loaders, and you want to use the result of the parent field's type Parent {
fieldOnParent: Child
}
type Child {
fieldOnChild: String
} In this case, I interpret your question as saying you're in the data fetcher for @DgsData(parentType = DgsConstants.CHILD.TYPE_NAME, field = DgsConstants.CHILD.FieldOnChild)
public CompletableFuture<String> fieldOnChild(DgsDataFetchingEnvironment dfe) {
DataLoader<String, String> dataLoader = dfe.getDataLoader(ChildDataLoader.class);
Child source = dfe.getSource();
// `MappedBatchLoaderWithContext` lets you load in the entire `source` as well
return dataLoader.load(source.getId(), source);
} Then you can extract the source (mapped by key) using Hope this helps |
Beta Was this translation helpful? Give feedback.
-
how can I implements such methods ?
public CompletableFuture<DataFetcherResult<List>> shows(...) {...
public DataFetcherResult<CompletableFuture<List>> shows(...) {...
Beta Was this translation helpful? Give feedback.
All reactions