Discussion - Pass context to resolve methods
See original GitHub issueThe context story seems very confused in the newest version. My understanding from the graphql-js 0.5.0 release notes is that all resolving functions should now have the signature ([self,] args, context, info)
, as opposed to ([self,] args, info)
.
At the moment, if I update a resolve_NAME
method to take context, then it throws argument errors.
Also, mutations don’t take context and therefore they cannot access context data. It think a patch similar to this one on graphql-relay-js is necessary for the relay mutations at least, but probably for all of them.
Issue Analytics
- State:
- Created 7 years ago
- Comments:19 (15 by maintainers)
Top Results From Across the Web
Pass context to a method that is declared in the base class
Is there a way to pass the context from one method to another without having to use the entity name of EntityName so...
Read more >Passing a context object to the constructor or to the method
Sometimes you want both - passing a global or root context into the constructor and an optional sub-context to the query/parse method.
Read more >Section 4. Techniques for Leading Group Discussions
Decide on an action; Provide mutual support; Solve a problem; Resolve a conflict; Plan your work or an event. Possible leadership styles of...
Read more >Context | Android Developers
Context. Public methods. bindIsolatedService; bindService; bindService ... Remove all permissions to access a particular content provider Uri that were ...
Read more >How to use React Context effectively - Kent C. Dodds
If it's just using the default value that's been provided, then it can't really do much good. 99% of the time that you're...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
In case anyone is also having troubles on how to access the context, after an endless effort/search I found on this link:
http://docs.graphene-python.org/projects/django/en/latest/authorization/
that I can access context like this:
if not info.context.user.is_authenticated():
Hope this helps anyone
According to the docs: http://docs.graphene-python.org/en/latest/types/objecttypes/
By default resolvers take the arguments args, context and info.
Followed by
As you can see, the example resolver method only has the
self
,info
andword
params. There was no usage ofargs
orcontext
at all, and no mention of what I should actually find passed ininfo
. I’m still digging around to try to understand what I should expect in these params. This is confusing and unpythonic. The expectation around function params is that if they’re positional, their actual names don’t matter. I had to find this issue to understand what you guys were even trying to do here. If your intent was to create a function that ignores some of its arguments, adding**kwargs
to the end to do so explicitly is the right way.