How to set LocalContext for each item in a list #902
Unanswered
VincentShaneFinn
asked this question in
Q&A
Replies: 1 comment 2 replies
-
|
In this case, you are probably better off encapsulating the context within a wrapper type that contains Alternatively, you could also do something like this: https://netflix.github.io/dgs/advanced/context-passing/#no-showid-use-local-context Hope that helps. |
Beta Was this translation helpful? Give feedback.
2 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.
-
https://netflix.github.io/dgs/advanced/context-passing/
We are using local context to pass internal ids to nested children. There is one use case I haven't seen an example for.
As far as I can tell, Graphql doesn't really distinguish between a single item or a list of items in the schema, and similarly in the DataFetchers.
So, if we had a fetcher that responded with one thing then setting a local context with some internal type is straightforward
However, if a Datafetcher returns a list then you can no longer set LocalContext for each individual item, and I don't know if there is a way to have a DateFetcher that resolves a SINGLE ITEM IN THE LIST, to override this context.
We have ended up having to set the LocalContext for each field for SomeType, and would be nice if we had access to a getSomeType Datafetcher, or something like that.
Beta Was this translation helpful? Give feedback.
All reactions