In resolver, Can I access request context?
See original GitHub issueclass TaskSchema(Schema):
id: int
title: str
is_completed: bool
owner: Optional[str]
lower_title: str
def resolve_lower_title(self, obj):
return self.title.lower()
I want to pass some value to hide some field. like this.
def resolve_lower_title(self, obj):
if context.is_code_valid:
return obj.title.lower()
else:
if obj.is_preview:
return obj.title.lower()
else:
return ''
Is it possible with resolver or another way? I can do this in drf serializer because they support getting context from view…
Issue Analytics
- State:
- Created a year ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Resolver mapping template context reference - AWS AppSync
Accessing the $context. The $context variable is a map that holds all of the contextual information for your resolver invocation. It has the...
Read more >Resolvers - Apollo GraphQL Docs
A resolver is a function that's responsible for populating the data for a single field in your schema. It can populate that data...
Read more >How do I access context and args in resolver at the same time?
You can access request headers by using this method. first add context in graphqlModule import in app.module.ts imports: [ GraphQLModule.
Read more >How To Access the request object inside a GraphQL resolver ...
Here, we are using es6 arrow functions and passing request object in that function.so that it will be available to pass in context...
Read more >RequestContext (Spring Framework 6.0.3 API)
Set the UrlPathHelper to use for context path and request URI decoding. Can be used to pass a shared UrlPathHelper instance in. A...
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 Free
Top 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
@quroom
well for this type of integration I would do it like this:
if you really want to collect data on schema level - then I would pass context to each item in the queryset:
thanks a lot!