Questions tagged [graphql-python]

For questions about python implementations of GraphQL query language. If an specific library is used, add that tag to the question too.

GraphQL is a query language for APIs created by Facebook. It's specification is currently public and can be checked here.

There are well known implementations for servers to support this query language, allowing them to build the typed schema or serve queries against that schema. Some of them are:

Use this tag to make questions about any of these, to ask something of one library compared to the other, to get best practices for implementing these, or others.

29 questions
8
votes
1 answer

Python GraphQL gql client authentication

I´m having hard time to use GraphQL with Python since the suggested library: gql is completely undocumented. How ever I found out that to provide the api url I need to pass a RequestsHTTPTransport object to Client like this: client =…
Macilias
  • 3,279
  • 2
  • 31
  • 43
8
votes
5 answers

How to filter a query by a list of ids in GraphQL using graphene-django?

I'm trying to perform a GraphQL query using Django and Graphene. To query one single object using the id I did the following: { samples(id:"U2FtcGxlU2V0VHlwZToxMjYw") { edges { nodes { name } } } } And it just works…
ilmorez
  • 328
  • 2
  • 8
6
votes
1 answer

Flask GraphQL import fails

I have the package versions ... Flask 2.0.2 Flask-GraphQL 2.0.0 Flask-Script 2.0.6 ... graphene 3.0 graphql-core 3.1.6 graphql-relay 3.1.0 graphql-server-core 1.1.1 ... and when I import…
orome
  • 45,163
  • 57
  • 202
  • 418
6
votes
1 answer

How to express input validations in GraphQL

I'm wondering how to express input types validation in the GraphQL Schema, for example: input DateFormat { format: String! } How can I express that format should be 10 chars max for example u other validations. Is this possible to implement…
Cheche
  • 1,456
  • 10
  • 27
5
votes
2 answers

Can a client subscribe to multiple graphql subscriptions in one connection?

Say we have a schema like this: type Subscription { objectAddedA: ObjectA objectAddedB: ObjectB } Can a graphql client subscribe to both the objectAddedA and objectAddedB subscriptions at the same time? I'm having a hard time finding good…
bieno002
  • 405
  • 1
  • 5
  • 12
5
votes
1 answer

"cannot query field 'id' on type CreateUser" with official Graphql tutorial

I am following the graphql-python tutorial on https://www.howtographql.com/graphql-python/4-authentication/. However, I get 3 errors saying "Cannot query field \"id\" on type \"CreateUser\"." I basically copied all source code in the tutorial and I…
Dustin Sun
  • 5,292
  • 9
  • 49
  • 87
4
votes
0 answers

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 even with a very small graph schema I still see a…
4
votes
1 answer

How to use variables in python-gql?

This function will return all users instead of the giving username, how could I make it right? And any better GraphQL client for Python? gql just so simple that no much documents could check. def fetch_user(username): query = gql(""" …
Leavlzi
  • 71
  • 1
  • 7
4
votes
1 answer

Python graphql exception handling: Is it expected to get errors array with 200 OK response?

According to the documentation in https://www.howtographql.com/graphql-python/6-error-handling/ I use raise GraphQLError to show errors in my Flask GraphQL app mutate functions, like this one: import graphene from graphql import GraphQLError from…
3
votes
1 answer

How to get Django Graphene ModelForm Mutation to apply

I'm trying to make this mutation create a new record in the database. It returns code 200 but no change to the database plus it returns null. The documentation is not clear on this issue.(ModelForm vs mutate function) Graphql response: { "data":…
Alan Karanja
  • 51
  • 1
  • 3
2
votes
2 answers

Set permissions on Graphene Relay Node and Connection fields

How can I require authentication/authorization on the tier Node field and allTiers Connection field query below? # schema.py class TierNode(DjangoObjectType): class Meta: model = Tier filter_fields = [] interfaces =…
atm
  • 1,684
  • 1
  • 22
  • 24
2
votes
0 answers

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 use or could be properly removed.
Stuart Moore
  • 681
  • 5
  • 32
2
votes
2 answers

I am new to graphql and I am finding difficulty in using schema from two different apps in django-graphql?

I am new to graphql and I am finding difficulty in using schema from two different apps in django-graphql? app1 hero schema.py import graphene from graphene_django import DjangoObjectType from .models import Hero class HeroType(DjangoObjectType): …
1
vote
0 answers

How to fill GraphQL ENUM from Django QuerySet?

In my graphql API for Revenue field use Currency enum from constant. from graphene import Enum CurrencyEnum = Enum('Currency', CURRENCY_CHOICES) class RevenueMetrics: revenue = graphene.Float(description='Revenue',…
1
vote
0 answers

What tool is best to use for GraphQL API Test automation framework building?

That supports BDD Runnable from the command line Supports Parallel tests Preferred with Python
Unnati Shukla
  • 342
  • 3
  • 15
1
2