Questions tagged [graphene-django]

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.

386 questions
47
votes
7 answers

import error 'force_text' from 'django.utils.encoding'

I'm implementing a graphql solution using python, graphene and django and I'm getting the following import error: Result: Failure Exception: ImportError: cannot import name 'force_text' from…
Gerd
  • 777
  • 1
  • 7
  • 12
18
votes
1 answer

Graphene-python performance issues for large data sets

Currently using graphene-python with graphene-django (and graphene-django-optimizer). After receiving a GraphQL query, the database query is successfully completed in a fraction of a second; however, graphene doesn't send a response for another 10+…
18
votes
2 answers

How to limit field access on a model based on user type on Graphene/Django?

Let's say I have a model: class Employee(models.Model): first_name = models.CharField(max_length=40) last_name = models.CharField(max_length=60) salary = models.DecimalField(decimal_places=2) I want anyone to be able to access…
Berry
  • 2,143
  • 4
  • 23
  • 46
14
votes
1 answer

Graphene-Django and many to many relationship lookup

I have two Django models - Teacher and Student and have a many-to-many relationship. Teachers can have multiple students and students can have multiple teachers. There is 'through' model called 'Remarks' where a teacher can mark a student as…
14
votes
0 answers

How to create custom filter using graphene-django and Relay that use multiple fields of different types?

Problem Hello, I'm using Graphene Django and Graphene Relay with Python 3.7. I'm trying to make a custom filter for the requests in GraphQL using Django filters. My table looks like this: | id(type: int) | flow(type: varchar) | datetime(type:…
user11928022
14
votes
1 answer

How can I upload and download files with graphene-django?

I'm currently using graphene-django v2.0 and I've absolutely no clue of how can I upload and download files like images, does anyone have an example of a query where you can download an Image and a mutation where you can upload one?
13
votes
1 answer

Field \"createUaction\" of type \"CreateUaction\" must have a sub selection."

This is the first time I am using graphene, ain't have a good grasp over it. So basically making a blog, where the user can like posts, comments and add posts to his favourite, and follow each other. I have made a separate model for all user…
Abhijeet Pal
  • 448
  • 1
  • 8
  • 21
11
votes
1 answer

How can exceptions in graphene-django be conditionally logged?

Whenever exceptions are raised they're logged in the console (and in Sentry if it's used). Many of these exceptions are only intended to be shown to the user. For example, django-graphql-jwt raises the PermissionDenied exception for the…
Daniel
  • 3,115
  • 5
  • 28
  • 39
9
votes
3 answers

How to get the Model ID in the Graphene Django Relay query?

How to receive the native Model ID that stored in the DB (eg. django model ID) when we are executing the Relay query? The main issue that the Relay defines it's own ID so I'm not sure how can we correctly handle it. For ex. query { allFuelTypes…
Velidan
  • 5,526
  • 10
  • 48
  • 86
9
votes
0 answers

How can I log information about a GraphQL request in Graphene Django?

Currently, Django logs: [16/Dec/2019 13:29:16] "POST /graphql HTTP/1.1" 200 1735 for any incoming graphql request. I'd like to be able to log more information about the incoming request (which queries, mutations, etc it is running). Is there a…
Octodone
  • 515
  • 6
  • 13
8
votes
3 answers

Django GraphQL JWT: tokenAuth mutation returns "str object has no attribute decode"

Currently I'm running a basic example of django-graphqljwt from the documentation page. https://django-graphql-jwt.domake.io/en/latest/quickstart.html import graphene import graphql_jwt class Mutation(graphene.ObjectType): token_auth =…
Dipanshu Juneja
  • 1,204
  • 14
  • 29
8
votes
1 answer

How can I define custom output types for mutations with graphene-django?

Create/remove/update/delete (CRUD) mutations usually return the corresponding database model instance as output type of the mutation. However for non-CRUD mutations I'd like to define business logic specific mutation output types. E.g. returning the…
thinwybk
  • 4,193
  • 2
  • 40
  • 76
7
votes
4 answers

ImportError: cannot import name 'force_text' from 'django.utils.encoding' (/usr/local/lib/python3.9/site-packages/django/utils/encoding.py)

I get the error below when I add 'graphene_django' inside INSTALLED_APPS in the settings.py. After running python3 manage.py runserver graphene_django is installed successfully using pip install django graphene_django This is full error that I…
Byusa
  • 2,279
  • 1
  • 16
  • 21
7
votes
2 answers

Graphene errors messages

I wonder if it is possible to translate the validation error messages that graphene provides? For example: "Authentication credentials were not provided" as shown in the code example below. { "errors": [ { "message": "Authentication…
7
votes
2 answers

How to resolve graphene.Union Type?

I want to create a UnionType(graphene.Union) of two existing types (FirstType and SecondType) and be able to resolve the query of this union type. Schema class FirstType(DjangoObjectType): class Meta: model = FirstModel …
liyapo
  • 151
  • 1
  • 10
1
2 3
25 26