Questions tagged [graphene-python]

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

Graphene is a Python library for building APIs with GraphQL easily. This tag covers question on usage of the core library as well as the graphene integrations with: Django, SQLAlchemy, GAE, Peewee, and PynamoDB.

Extensible Framework

623 questions
28
votes
4 answers

Best way to construct a GraphQL query string in Python

I'm trying to do this (see title), but it's a bit complicated since the string I'm trying to build has to have the following properties: mulitiline contains curly braces I want to inject variables into it Using a normal '''''' multiline string…
Tobias Feil
  • 2,399
  • 3
  • 25
  • 41
23
votes
2 answers

graphene graphql dictionary as a type

I'm a newbie for the graphene and I'm trying to map the following structure into a Object Type and having no success at all { "details": { "12345": {"txt1": "9", "txt2": "0"}, "76788": {"txt1": "6", "txt2": "7"}, } } Any…
Asce4s
  • 819
  • 3
  • 10
  • 16
22
votes
4 answers

How to consume the Github GraphQL API using Python?

I want to access details from Github using Github GraphQl v4 API. I found Graphene library, but I'm not sure how to authenticate with a personal access token in Python. I tried to search on Google but couldn't found any example. It's Python library…
Vaibhav Singh
  • 1,554
  • 3
  • 13
  • 27
22
votes
3 answers

graphene-django - How to filter?

I use graphen-django for build a GraphQL API. I have succesfully create this API, but I can't pass a argument for filter my response. This is my models.py: from django.db import models class Application(models.Model): name =…
Nevenoe
  • 1,032
  • 3
  • 14
  • 37
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

Enable PK based filtering in Django Graphene Relay while retaining Global IDs

Problem I am using django-graphene with Relay on our GraphQL Server. The implementation imposes a Global ID requirement in the graphene.relay.Node class that overrides and hides Django's ID field. As a result, I can query like this: { …
rtindru
  • 5,107
  • 9
  • 41
  • 59
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
17
votes
5 answers

How to return json in python graphene resolver without backslashes before quotation marks

I have a backend server in python (Flask + Graphene) and I need to return a JSON object like this: { 's1': "Section 1", 's2': "Section 2", 's3': "Section 3", 's4': "Section 4" } The resolver looks like below: questionnaire…
John Overiron
  • 517
  • 1
  • 5
  • 20
16
votes
1 answer

Using django_filters on graphene queries while not using Relay

While using graphene with Relay in django, there is an option to use filtering while querying the data. class AnimalNode(DjangoObjectType): class Meta: model = Animal filter_fields = ['name', 'genus', 'is_domesticated'] …
Mehran
  • 1,264
  • 10
  • 27
15
votes
0 answers

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 is my python scheme implementation: class…
Pavel Reznikov
  • 2,968
  • 1
  • 18
  • 17
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
1 answer

Graphene Django - Mutation with one to many relation foreign key

I would like to know how to properly create mutation for creating this django model: class Company(models.Model): class Meta: db_table = 'companies' app_label = 'core' default_permissions = () name =…
idature
  • 491
  • 7
  • 23
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
13
votes
5 answers

Apollo-client returns "400 (Bad Request) Error" on sending mutation to server

I am currently using the vue-apollo package for Apollo client with VueJs stack with django and graphene-python for my GraphQl API. I have a simple setup with vue-apollo below: import Vue from 'vue' import { ApolloClient } from 'apollo-client' import…
Feyisayo Sonubi
  • 1,052
  • 5
  • 15
  • 27
1
2 3
41 42