Skip to content

Best practices for using "contextValue" #1126

Answered by mfn
illambo asked this question in Q&A
Discussion options

You must be logged in to vote

but one could pass a more structured object/array what he needs (user, tenancy, dataloaders?, ..)

But no one is stopping you from doing so: just return new YourSuperChargedContext, you even type hint it in every resolver.

That's what I do and the context holds some requested-shared information, which is quite useful.

Though in recent years I reduced the "shared state" as much, it's like a global var and thus always prone to create hard to predict code.

But anyway, it's possible. Or did I misunderstand?

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@illambo
Comment options

@mfn
Comment options

Answer selected by illambo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants