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
3
votes
3 answers

How to show specific field only to the user profile owner in graphene-django?

I have the following schema in my graphene-django application: import graphene from django.contrib.auth import get_user_model from graphene_django import DjangoObjectType class UserType(DjangoObjectType): class Meta: model =…
ruohola
  • 21,987
  • 6
  • 62
  • 97
3
votes
1 answer

How to format dates and datetime in graphene

I want graphene to output normal date/datetime formats. By default it returns this: `"createdAt": "2019-06-11T05:48:11.023255+00:00",` And I want it to return this: `"createdAt": "11.06.2019 11:48:11",` It seems there is no such option in graphene…
nrgx
  • 325
  • 3
  • 13
3
votes
1 answer

Graphql type included in interface not added to schema in graphene-django

I have an interface type implemented by two concrete types interface InterfaceType { id: ID! name: String! } type Type1 implements InterfaceType { aField: String } type Type2 implements InterfaceType { anotherField: String } Using…
jorgen
  • 3,425
  • 4
  • 31
  • 53
3
votes
1 answer

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 get_node method, didn't work either. This is a…
Rodgers Ouma
  • 103
  • 2
  • 13
3
votes
1 answer

Exposing GraphQL based APIs

I have data stored in the file system (normalized across multiple small files) and I have written python functions to read/write data from the file system. Read API returns object of type Job. Write API expects an object of type Job to be passed as…
ThinkGeek
  • 4,749
  • 13
  • 44
  • 91
3
votes
1 answer

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 add the int pk field from the model; however, I…
Jeff Tratner
  • 16,270
  • 4
  • 47
  • 67
3
votes
1 answer

Graphene and Django about relationships

I'm very new to Graphene and testing it to see if i could use it for a Django project with complex queries. To test it, i'm trying to create an Ecommerce with the following models class Sku(models.Model): name =…
2
votes
1 answer

How can I can not raise error in mutations with graphene django?

I'm using graphene-django-cud for mutations. But I can't raise any GraphQLError, ValueError or Exception in mutations. Like in before_mutate() or any validate_ method. The process just stop with out any error message. Then return null for the…
2
votes
1 answer

How to do mutation query in GraphQL in Django?

# Model class Customer(models.Model): name = models.CharField(max_length=150) address = models.CharField(max_length=150) # Node class CustomerNode(DjangoObjectType): class Meta: model = Customer interfaces =…
2
votes
1 answer

Graphene-file-upload handling the multipart/form-data

I am trying to upload an image from my react/nextJS front end to my Django backend using graphQL and graphene-file-upload. Following this: https://github.com/lmcgartland/graphene-file-upload and this…
Fabian Omobono
  • 81
  • 2
  • 13
2
votes
1 answer

How to create a graphql mutation with a relation in Django

I have a problem with creating mutations in graphql that contain a relation. I don't know where to start. For example - three classes of models: class HotelGuests(models.Model): id = models.UUIDField(primary_key=True, …
2
votes
1 answer

How to declare variables in a GraphqQL query using the gql client?

I'm new with GraphQL schemas and I would like to do a mutation using the gql client. The query below works like a charme in the graphql web interface after replacing the 5 variables with the corresponding strings and integers. But when I put a $…
Florent
  • 1,791
  • 22
  • 40
2
votes
1 answer

GraphQL query returning duplicate results

I have a GraphQL schema that returns orders and the products that are part of that order. I have added a filter to return only orders that contains products searched for by the user. This filter is done on a icontains. However I have found that if a…
Ross
  • 2,463
  • 5
  • 35
  • 91
2
votes
1 answer

Add user to model before saving with DjangoModelFormMutation

I have a Django Log model which has many-to-one with a User from django.db import models class Log(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) ... I have a Django form for the Log from django.forms import…
Tintin
  • 547
  • 5
  • 17
2
votes
1 answer

Graphene input error for Pydantic models with discriminator while generating Input object schema

I am using pydantic validations for my requirements and it uses discriminator. I am writing GraphQL APIs and want to convert those pydantic models into graphene input objects. Below is my code. from graphene_pydantic import PydanticInputObjectType,…
mc-user
  • 1,769
  • 4
  • 14
  • 25