-
-
Notifications
You must be signed in to change notification settings - Fork 567
Allow context to be scoped #1385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
6ee78e9
to
cef780a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was fast 🚀
892fd86
to
9f4fec6
Compare
@spawnia The PR is ready for review. I'd love to hear what you think. If you have suggestions on how to improve this, please let me know |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's figure out where this can be documented. I think at least the PHPDoc that describes $contextValue
should be extended, perhaps an entire new section of docs can be added?
545bc8b
to
698d617
Compare
@spawnia Ready. Added a few lines to the documentation. I think it's sufficient. |
Concerning docs, I would like to provide an example. The pull request description does not seem right:
Again, I think the following is still true:
See Lines 47 to 51 in 01d7b25
|
By implementing the ScopedContext interface on your context object, you can ensure that scope is only passed downwards and not shared with other fields. Example: ```graphql query { a { b { c } d { e { f } } } g { h { i } } } ``` In the above situation, the following will happen: * `a` receives the cloned context from the executor * `b` receives the cloned context from `a` * `c` receives the cloned context from `b` * `d` receives the cloned context from `a` * `f` receives the cloned context from `e` * `g` receives the cloned context from the executor * `h` receives the cloned context from `g` * `i` receives the cloned context from `h` References: graphql/graphql-js#2692 rmosolgo/graphql-ruby#2634
@spawnia Updated the PR. If you have better wording, please let me know. |
@spawnia Thanks for merging it, would love to have it tagged if you have time 🙏 💙 nvm: I see the PR already. |
…lemented on the Context, it would clone the context down to it's children. This works great for queries. But mutations are executed serially. I forgot to call `maybeScopeContext` there. This fixes the problem, and adds a test to guard it.
In webonyx#1385 we introduced the `ScopedContext` interface. When implemented on the Context, it would clone the context down to it's children. This works great for queries. But mutations are executed serially. I forgot to call `maybeScopeContext` there. This fixes the problem, and adds a test to guard it.it would clone the context down to it's children.
In #1385 we introduced the `ScopedContext` interface. When implemented on the Context, it would clone the context down to it's children. This works great for queries. But mutations are executed serially. I forgot to call `maybeScopeContext` there. This fixes the problem, and adds a test to guard it.it would clone the context down to it's children.
By implementing the
ScopedContext
interface on your context object, you can ensure thatscope is only passed downwards and not shared with other fields.
Example:
In the above situation, the following will happen:
a
receives the cloned context from the executorb
receives the cloned context froma
c
receives the cloned context fromb
d
receives the cloned context froma
e
receives the cloned context fromd
f
receives the cloned context frome
g
receives the cloned context from the executorh
receives the cloned context fromg
i
receives the cloned context fromh
References: