Use this tag for questions about Graphene-Django, integration features of Graphene (a framework for building GraphQL APIs) that are designed to make working with Django simple.
Questions tagged [graphene-django]
386 questions
7
votes
4 answers
Delete mutation in Django GraphQL
The docs of Graphene-Django pretty much explains how to create and update an object. But how to delete it? I can imagine the query to look like
mutation mut{
deleteUser(id: 1){
user{
username
email
}
error
}
}
but i…

karlosss
- 2,816
- 7
- 26
- 42
6
votes
0 answers
Graphene is sending Python error messages in its response - how do I tell it to be more discrete?
I have implemented a GraphQL server in Python using Django and Graphene. I have mutations that use modelforms, which broadly look like this:
def mutate(self, info, **kwargs):
form = MyModelForm(kwargs)
if form.is_valid():
…

Sam Ireland
- 512
- 4
- 20
6
votes
1 answer
Graphene-Django - how to pass an argument from Query to class DjangoObjectType
First of all, thanks ! it has been 1 year without asking question as I always found an answer. You're a tremendous help.
Today, I do have a question I cannot sort out myself.
Please, I hope you would be kind enough to help me on the matter.
Context:…

Cédric
- 61
- 5
5
votes
3 answers
Is there a way to elegantly use a django model as an input object type?
Say I have,
class PersonNode(DjangoObjectType):
class Meta:
model = Person
fields = ('first_name', 'last_name', 'age',
'sex', 'alive', 'unique_identifier',)
filter_fields = ('first_name', 'last_name',…

user1849962
- 1,273
- 1
- 11
- 16
5
votes
3 answers
How to hide/exclude certain fields of foreign key in graphene_django wrt the requested entity?
I have read about how to exclude (hide) certain fields in django and graphene_django in these Links:
graphql-python repository
Why does my excluded field still appear in this Django form?
etc.
Imagine that we have the following Post model which…

Mostafa Ghadimi
- 5,883
- 8
- 64
- 102
5
votes
3 answers
How can I use a single enum for django model and graphql mutation arguments?
I've defined Django models with fields containing text choices corresponding to enums. The GraphQL API provides mutations (which are not derived from models directly) with arguments of type enum which shall accept the same values as the models only.…

thinwybk
- 4,193
- 2
- 40
- 76
5
votes
1 answer
Python Graphene working with many to many relations
if this is answered somewhere else then I am sorry but 2 days after work and still no cigar...
I have a player model:
class Player(models.Model):
name = models.CharField(max_length=60)
discord_id = models.CharField(max_length=60,…

Tackgnol
- 483
- 1
- 9
- 15
5
votes
1 answer
What is the recommended best practice to separate public and private APIs in graphene-django?
I have seen a number of discussions on how to implement a permission system in graphene, but have not seen any definitive practical outcome beyond these discussions. Some examples of discussions on this topic are:
Permission System
How do you…

martasd
- 111
- 1
- 1
- 8
4
votes
1 answer
DjangoListField() vs graphene.List() in Graphene Django
I used both "DjangoListField()" and "graphene.List()" with the Resolver to list all objects.
"DjangoListField()" in schema.py:
import graphene
from graphene_django import DjangoObjectType
from graphene_django import DjangoListField
from .models…

Super Kai - Kazuya Ito
- 22,221
- 10
- 124
- 129
4
votes
1 answer
TemplateDoesNotExist graphene/graphiql.html
I'm trying to setup Graphene, but have a following exception raised when open http://localhost:8000/graphql/ in browser:
TemplateDoesNotExist at /graphql/
graphene/graphiql.html
Request Method: GET
Request URL: …

wowkin2
- 5,895
- 5
- 23
- 66
4
votes
1 answer
Calling a custom method in a Graphene python resolver
Hello I simply want to avoid repeating code for each query, and I was wondering if I could call a method from inside a resolver a such:
# pseudo code
class Query(graphene.ObjectType):
field = graphene.Field(SomeType)
def…

Andrew Jouffray
- 109
- 2
- 9
4
votes
0 answers
How to serialize a Django model using Graphene-Django outside the context of a graphQL query
I'm using Graphene-Django to build a GraphQL API, and I've defined object types as explained in the docs. By way of example,
import graphene
from graphene_django import DjangoObjectType
from .models import Question
class…

bjmc
- 2,970
- 2
- 32
- 46
4
votes
0 answers
How can I make my graphene-python API respond faster?
I've built a python/daphne/django/graphene server, and did everything I could to optimize my queries -- cached db queries in Redis so that they are basically free, and eventually came to find that even with a very small graph schema I still see a…

Tyler Gannon
- 872
- 6
- 19
4
votes
0 answers
Is there a way to retrieve Enum description instead of name in a GraphQL API made with Django Graphene
This question is more about what's the best practice than how to monkey-patch Graphene to accomplish what I want.
Django Graphene turns model's choices automagically in enums.
Lets say I have this model:
class Car(models.Model):
brand =…

Cristian Rojas
- 2,746
- 7
- 33
- 42
4
votes
1 answer
Aggregating fields in graphene/django queries
I am writing a graphene/django ORM query, where I need to aggregate the values of a particular field on all my query result objects and return it with the query. Not quite sure how to do that, as this involves some post-processing. Would appreciate…

BoomDizzle
- 188
- 1
- 1
- 12