Custom argument on DjangoObjectType
See original GitHub issueHi all 👋🏻,
I’ve seen #333 but still have a question about how to add a custom argument that’d enable a more complex filter on a DjangoObjectType
.
Using graphene-django==2.8.0
.
class ThingNode(DjangoObjectType):
class Meta:
model = Thing
interfaces = (graphene.relay.Node,)
@classmethod
def get_queryset(cls, queryset, info):
# How do I access my_custom_param here to enable a custom filter?
if my_custom_param:
# Heavily modify the queryset here with filter + exclude
queryset.filter().filter().exclude()
else:
# Something else
queryset.filter().filter()
return queryset
class Query(graphene.ObjectType):
things = DjangoFilterConnectionField(ThingNode, my_custom_param=graphene.Boolean())
Issue Analytics
- State:
- Created 4 years ago
- Comments:5
Top Results From Across the Web
A custom argument in graphene-django - Stack Overflow
How do I create a custom argument in GraphQL with graphene-django? I currently have this configuration in my schema.py: class Post( ...
Read more >Queries & ObjectTypes - Graphene-Python
This allows you to provide input arguments in your GraphQL server and can be useful for custom queries. import graphene from .models import...
Read more >Django + Graphene: From REST to GraphQL - FullStack Labs
player/types.py from graphene_django.types import DjangoObjectType from ... Mutation): class Arguments: # The input arguments for this mutation id ...
Read more >How to use the graphene.Float function in graphene - Snyk
DjangoObjectType ): class Meta(object): model = HasRead class Query(graphene. ... ObjectType): """ Querry for the calendar events and accepts the arguments ...
Read more >graphene-django-extras - PyPI
Argument (UserInput) class Meta: description = " Graphene traditional ... You must add the directives param with your custom directives to your schema ......
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
Did find a way to support this but it feels like I’m dipping into internals that I shouldn’t be?
@msukmanowsky, Thank you! Your answer is the solution i was looking for.