Questions tagged [graphene-python]

Graphene is a Python library for building APIs with GraphQL easily.

graphene-python
253 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
22 votes
1 answer
2k views

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, ...
techknowfile's user avatar
18 votes
1 answer
1k views

Mutation for nested object

I'm trying to implement GraphQL mutation for a "complex" object. Let's say we have a Contact with three fields: firstName, lastName and address, which is object with one field street: Here ...
Pavel Reznikov's user avatar
14 votes
1 answer
2k views

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 '...
dotslash227's user avatar
10 votes
1 answer
2k views

Graphene: "Expected a value of type XXX but received: ..."

I'm using graphene-django to build my API. I have a DjangoObjectType named StoreType which represents the model Store. This model has a MultiSelectField named opening_days that indicates what days in ...
martin's user avatar
  • 887
9 votes
0 answers
743 views

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,...
Octodone's user avatar
  • 555
8 votes
0 answers
884 views

Auth0 - Django and Graphene

Im currently using Graphql with Django Graphene JWT. Im using django for the backend. All requests are authed by the token shown below: I have a schema that creates auth tokens for graphql that ...
Harry's user avatar
  • 13.2k
6 votes
0 answers
1k views

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(...
Sam Ireland's user avatar
6 votes
0 answers
4k views

Enums in Django and Graphene always result in null

I am having some issues trying to use enums with Django and Graphene. Even though the values of the enum are persisted in the SQLite and are retrieved properly, it keeps resulting in an error. Below ...
Christopher Z's user avatar
5 votes
0 answers
960 views

how to serialize a nested json inside a graphene resolve?

I am studying the library graphene, (https://github.com/graphql-python/graphene) and I was trying to understand how I can serialize / return a nested json into the graphene and perform the query in ...
jonathan's user avatar
5 votes
1 answer
744 views

How can I filter / post-process a Python-Graphene result

I'm currently writing a GraphQL API with Python-Graphene. One resolver provides a list of entries, and I'd like to do some post-processing / filtering here. However, the properties of the child ...
Oliver's user avatar
  • 51
5 votes
1 answer
832 views

Authentication/Authorization for default resolvers

I read the description on how to use @login_required and other decorators with resolvers. However, if one is not using explicit resolvers (instead using default ones), how can one enforce similar ...
Alonso's user avatar
  • 51
5 votes
0 answers
1k views

Integrating AWS AppSync (+ Cognito) Schema with Graphene django on lambda

I've an AWS AppSync GraphQL endpoint with some DynamoDB tables and it is integrated with Cognito. I've also developed a django application with graphql endpoint (graphene) and cognito integration ...
Alp Güneysel's user avatar
5 votes
0 answers
474 views

How to query translatable fields with graphene

Assuming a model that has translated fields like below, how can we query these with django-graphene? from parler.models import TranslatableModel, TranslatedFields class Article(TranslatableModel): ...
fekioh's user avatar
  • 946
4 votes
0 answers
140 views

How can I make Graphene resolvers run concurrently

I have a graphene query that looks similar to below where I have more than 1 resolver function. These queries run sequentially per the Django debug toolbar. Even though these queries are not dependent ...
anthony-dandrea's user avatar
4 votes
0 answers
674 views

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 ...
bjmc's user avatar
  • 3,111
4 votes
0 answers
1k views

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 ...
Tyler Gannon's user avatar
4 votes
0 answers
291 views

How can I get object field descriptions to ouput with a Graphene GraphQL schema?

I have my graphql schema implemented in graphene, with the a test object and schema object being: class Test(ObjectType): id = ID(description='Test ID') test_string = String(description='Test ...
Josh's user avatar
  • 61
4 votes
1 answer
1k views

How to pass complex types as arguments in graphene Python

I'm trying to create a query that accepts a complex argument object like so: class Pair(graphene.ObjectType): x = graphene.Int() y = graphene.Int() class Pairs(graphene.ObjectType): pairs = ...
Peteris's user avatar
  • 3,656
4 votes
0 answers
636 views

Cannot order by two fields using django filter in graphene-django

I am using DjangoFilterConnectionField in my project like this: all_sessions = DjangoFilterConnectionField(SessionNode, filterset_class=AgendaFilter) SessionNode is created based on Session model in ...
martasd's user avatar
  • 125
4 votes
0 answers
337 views

How to autodocument graphql query in graphene-django?

With graphene-django when documenting e.g. GraphQL object type classes the docstrings are usually used to autogenerate documentation which is visible in GraphiQL. This should also work with plain ...
thinwybk's user avatar
  • 4,513
4 votes
1 answer
383 views

get_node method is not called

I am experiencing an issue with get_node method in a django object type definition. The method doesn't seem to be called in my case. I even tried debugging with pdb by pausing execution inside the ...
Rodgers Ouma's user avatar
4 votes
0 answers
548 views

unable to create a SerializerMutation without errors, but data is created

I do not why but when I try to create new data using serializermutation, data is created but graphiql return an error. Here is my code. graphene(2.1) _graphene_django(2.0.0)_ models class ...
Alberto Diaz's user avatar
4 votes
0 answers
882 views

Invalid SQLAlchemy Model when automapping database to graphene

I'm trying to work with graphene-sqlalchemy on an existing database I'm automapping. database automapping: engine = create_engine(" blablabla", convert_unicode=True) db_session = scoped_session(...
Rémy V.D's user avatar
  • 260
4 votes
1 answer
2k views

Graphene-Django nested filters (relay)

I'm trying to achieve the following using graphene-django's DjangoFilterConnectionField: { allUsers(username_Icontains: "abc") { edges { node { id demographics (...
morinx's user avatar
  • 635
4 votes
0 answers
421 views

How to pass variables to an Apollo Mutation for Graphene?

I'm currently trying to switch from an Apollo server in nodejs to a Graphene server, but I'm having an issue while mutating. Client side handling const GeneratedForm = Form.create()(...
dbrrt's user avatar
  • 2,400
4 votes
1 answer
643 views

How to use django default group permission in django-graphene?

I want to do a API with django-graphene, but i want to apply the django default group permission when i user make a request this will have permission if his user-group allow him to CRUD. Thanks.
Nestor Moran's user avatar
3 votes
0 answers
658 views

With Graphene GraphQL, is it possible to cache the queryset used for Relay Connections (pagination)?

When using Graphene's Relay Connection field, it's very easy to paginate though a queryset. The client passes the arguments (first, after, before, last), then by returning a queryset the resolver ...
MDalt's user avatar
  • 1,761
3 votes
0 answers
2k views

How to use graphene dataloader on connections and how to select only necessary fields

I would like to use some non-standard database with python graphene to create a GraphQL endpoint. This database doesn't have existing SQLAlchemy dialect, is not supported by Django ORM etc., so I'm ...
Роман Коптев's user avatar
3 votes
2 answers
3k views

Returning a list of enums with string values with Graphene

This is using Python and the Graphene library. I want to provide a list of constants to my front-end via GraphQL. I went down the route of using inspection, but it will only output the keys of the ...
Envin's user avatar
  • 1,503
3 votes
0 answers
185 views

Share Meta classes between two SQLAlchemyObjectType

I'm using graphene_sqlalchemy package in my Flask app (https://github.com/graphql-python/graphene-sqlalchemy) and I need to make two queries using the same Model. I was wondering if is possible two ...
Harrison Henri's user avatar
3 votes
1 answer
462 views

Combine DjangoObjectType with ObjectType - Django, GraphQL

I'm trying to combine DjangoType with ObjectType. I have models: class Scenario(models.Model): id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) name = models....
kasia's user avatar
  • 298
3 votes
1 answer
1k views

Django-graphene multiple types for the same model

I have a quite big graphene-django API which feeds two applications. My first approach to restrict access to some fields was to have multiple DjangoObjectTypes for the same model, and use fields to ...
Christian Bouvier's user avatar
3 votes
1 answer
689 views

Is there any way to remove edges and node when using DjangoFilterConnectionField?

i started to use graphene with django and for right now i don't need all that overhead of edges and node, i know it's for pagination but right now i only need the fields of my model. To be clear, i ...
ריף הורביץ's user avatar
3 votes
0 answers
456 views

Is there a way to specify type converters for graphene input types?

Lets say I have the following GraphQL schema written in graphene, class Query(graphene.ObjectType): dummy_query = graphene.Field(String, name=graphene.String(required=True)) def ...
Nithin's user avatar
  • 159
3 votes
0 answers
514 views

Graphene Django filter by generic relation

I am using graphene-django with django-filter. Got problem with filtering object with django's GenericForeignKey. I tried custom FilterSet but no luck. So here are my models and schema. class Feature(...
Zorig's user avatar
  • 605
3 votes
0 answers
1k views

How to send array of objects with graphql mutation

I have grapgql mutation as follows: const RESET_PASSWORD = gql` mutation ResetPassword($input: [ResetPasswordInput]!) { resetPassword(input: $input) { ok } } `; And the function ...
Boky's user avatar
  • 11.9k
3 votes
1 answer
1k views

Look up by primary key in graphene-django (with relay)

I'd like to be able to write a query that looks like this, using a human primary key rather than the opaque relay IDs: query { issue(pk: 10) { pk state } } I've been able to ...
Jeff Tratner's user avatar
  • 16.7k
3 votes
1 answer
975 views

Select requested-only fields from DB with GraphQL and Graphene-Python

I'm building a Python Flask-GraphQL API using Graphene and was wandering if there are any common solutions to requesting only required fields from DB in resolvers. Let's say there's a request of a ...
Yan Sidorov's user avatar
3 votes
1 answer
380 views

"Unknown type \"CreateAccountInput\". with graphene_django when trying to mutate/create new object

I'm new to graphQL and I've just been trying to create a new account object with it. This is my code right now but it the GUI for graphQL I keep getting the "Unknown type \"CreateAccountInput" error. ...
Amon's user avatar
  • 2,851
3 votes
1 answer
1k views

graphql code organization for scalable projects

Think that we have a big project with lots of apps which results in lots of queries and mutations. For such projects, how do you people handle the graphql code architecture. Let's take an example. I ...
Tushant's user avatar
  • 1,534
3 votes
0 answers
836 views

graphene django with redis does not work?

I have a resolver and I gave it a key to save into django-redis, I can see the key and value inside redis but somehow the loading time is still the same. If I am doing a regular rest it will work ...
Dora's user avatar
  • 6,908
3 votes
0 answers
521 views

Graphene: How to share InputObjectType for different resolver?

I would like to not define the input variables multiple times when they are equivalent for all resolver. How can I achieve that? import graphene class GeoInput(graphene.InputObjectType): lat = ...
Peterhack's user avatar
  • 1,021
3 votes
2 answers
2k views

Python GraphQL variable not defined

I'm trying to do a GraphQL request that contains some variables using the apollo-boost client on a Flask + Flask-GraphQL + Graphene server. let data = await client.query({ query: gql`{ ...
Niklas R's user avatar
  • 16.6k
3 votes
3 answers
2k views

How do you write a resolver that returns a SQLAlchemy as a relay connection?

I would like to return a relay connection for queries. Using standard graphene-sqlalchemy you can do this: class Query(graphene.ObjectType): node = relay.Node.Field() all_users = ...
Wichert Akkerman's user avatar
3 votes
0 answers
1k views

How can I write nested GraphQL mutations in graphene?

I am trying to write nested mutations in graphene, but run into trouble passing the output of one mutation to another. I would like the WriteImage resolver to able to accept its input image from the ...
Kasper Marstal's user avatar
2 votes
0 answers
264 views

Django - working example of graphene aiodataloader

I've been looking into using a DataLoader in Django to optimise Graphene resolvers. I have been having trouble finding a working example of this as it requires multi threading. Based on what I can ...
Sthe's user avatar
  • 2,635
2 votes
0 answers
286 views

How to combine DjangoObjectType and an additional field in one query?

I have a DjangoObjectType class and its query as below. class ExampleType(DjangoObjectType): class Meta: model = Example interfaces = (relay.Node,) order_number = String() ...
Aslı Kök's user avatar
2 votes
0 answers
419 views

Using Django's GenericForeignKey with Async Graphene Subscription

I've implemented graphql_ws to subscribe to updates from a Notification model that uses multiple GenericForeignKeys. My setup works well, except when I try to query information from those foreign ...
soukiab's user avatar
  • 21
2 votes
0 answers
306 views

Log use of deprecated fields in python graphene

Is there a way to automatically log any queries that involve a deprecated field (i.e. one with a non-null deprecation_reason)? It'd be helpful to help work out whether a deprecated field was still in ...
Stuart Moore's user avatar
2 votes
1 answer
118 views

DjangoListField analouge for an individual object resolver

I am using Django + GraphQL and it is extremely convenient to use DjangoListField. It allows me to override get_queryset at the ObjectType level and make sure all permissions verified there. In that ...
Andrii Zarubin's user avatar

1
2 3 4 5 6