Is there a way to grab the parent argument in a DgsData function? #1032
-
|
Given a schema like this type Actor {
name: String
movies(size: Int): [Movie]
}
type Movie {
name: String
}
type Query {
actor(id: String)
}and given a movie field implementation. is there a way to grab the @DgsData(parentType = "Actor", field = "movies")
fun movies(dfe: DgsDataFetchingEnvironment, @InputArgument size: Int): List<Movie> {
val id = dfe.arguments["id"] as String? ?: ""
return movieService.getMoviesByActorId(id, size)
}
Currently |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
|
You can pass any additional information as part of the context to child data fetchers, so you could add it there: https://netflix.github.io/dgs/advanced/context-passing/#no-showid-use-local-context The other alternative for the parent is to inspect the Data fetching environment that's passed in and extract it, a bit more convoluted. Hope this helps. |
Beta Was this translation helpful? Give feedback.
You can pass any additional information as part of the context to child data fetchers, so you could add it there: https://netflix.github.io/dgs/advanced/context-passing/#no-showid-use-local-context
The other alternative for the parent is to inspect the Data fetching environment that's passed in and extract it, a bit more convoluted.
Hope this helps.