graphene-python

Retrieve the object ID in GraphQL

大憨熊 提交于 2021-02-07 14:47:00
问题 I'd like to know whether it is possible to get the "original id" of an object as the result of the query. Whenever I make a request to the server, it returns the node "global identifier", something like U29saWNpdGFjYW9UeXBlOjEzNTkxOA== . The query is similar to this one: { allPatients(active: true) { edges { cursor node { id state name } } } and the return is: { "data": { "edges": [ { "cursor": "YXJyYXljb25uZWN0aW9uOjA=", "node": { "id": "U29saWNpdGFjYW9UeXBlOjEzNTkxOA==", "state": "ARI",

Retrieve the object ID in GraphQL

拈花ヽ惹草 提交于 2021-02-07 14:44:35
问题 I'd like to know whether it is possible to get the "original id" of an object as the result of the query. Whenever I make a request to the server, it returns the node "global identifier", something like U29saWNpdGFjYW9UeXBlOjEzNTkxOA== . The query is similar to this one: { allPatients(active: true) { edges { cursor node { id state name } } } and the return is: { "data": { "edges": [ { "cursor": "YXJyYXljb25uZWN0aW9uOjA=", "node": { "id": "U29saWNpdGFjYW9UeXBlOjEzNTkxOA==", "state": "ARI",

How we can make filtered query in schema.py in graphene-django project without using Relay feature?

試著忘記壹切 提交于 2021-01-29 13:26:15
问题 I am new to back-end programming especially in graphene-django. my question is how can we create filtered query in schema.py in graphene-django project without using Relay feature? i saw this before but i don't want to use Relay feature. rather than i want use a filter, but i don't know how?? now my models.py and schema.py look-like these: *models.py # shoes_store/ingredients/models.py from django.db import models class Category(models.Model): name = models.CharField(max_length=50) notes =

GraphQL and Graphene

别说谁变了你拦得住时间么 提交于 2021-01-29 03:34:54
问题 I have a database schema that has a one to many relationship. For e.g. one department has many customer. Is it possible to have a mutation that create a customer and a department and associate them? Or the correct way is to create a customer than a department and then associate each other? In the second approach I need to make three trips instead of one. Can someone provide me a GraphQL handling this situation? 回答1: You can define your mutation input to support nested types. This will allow

Setting up a plain graphene nested query

主宰稳场 提交于 2021-01-27 23:03:44
问题 I have successfully created an all graphene query that responds to query { person (id: "Mary") { id name } } I now want to extend this to be able to loop through all people and return similar data for each. query { people { count allPersons { name } } } How do I get the resolve_allPersons resolver in people to call the person resolver for each person? 回答1: Second query you've described can be done with custom type, for example: class AllPeopleType(graphene.ObjectType): count = graphene.Int()

Setting up a plain graphene nested query

被刻印的时光 ゝ 提交于 2021-01-27 21:42:57
问题 I have successfully created an all graphene query that responds to query { person (id: "Mary") { id name } } I now want to extend this to be able to loop through all people and return similar data for each. query { people { count allPersons { name } } } How do I get the resolve_allPersons resolver in people to call the person resolver for each person? 回答1: Second query you've described can be done with custom type, for example: class AllPeopleType(graphene.ObjectType): count = graphene.Int()

Using json model field with django graphene

帅比萌擦擦* 提交于 2021-01-27 18:04:01
问题 I'm working with graphql endpoint for my project. One of models has textfield which contains some json. If i request list of my entities via graphql, I'm getting this json like a string. How to reach ability to use it in graphql as nested structure with ability of filtering, choosing some properties etc. class SysObjects(models.Model): id = models.BigAutoField(primary_key=True) user_id = models.BigIntegerField() type_id = models.PositiveIntegerField(blank=True, null=True) # status = models

Using json model field with django graphene

陌路散爱 提交于 2021-01-27 17:19:43
问题 I'm working with graphql endpoint for my project. One of models has textfield which contains some json. If i request list of my entities via graphql, I'm getting this json like a string. How to reach ability to use it in graphql as nested structure with ability of filtering, choosing some properties etc. class SysObjects(models.Model): id = models.BigAutoField(primary_key=True) user_id = models.BigIntegerField() type_id = models.PositiveIntegerField(blank=True, null=True) # status = models