graphene-python

Choosing the correct Schema for Graphene in a Flask request

Choosing the correct Schema for Graphene in a Flask request Question: I have a Flask GraphQL endpoint that looks like: app.add_url_rule(‘/graphql’, view_func=GraphQLView.as_view( ‘graphql’, schema=schema, graphiql=True, )) I currently have 3 different schemas. As far as I know, one of the differences between GraphQL and REST is that in GraphQL you just define a single base …

Total answers: 1

GraphQL query returning duplicate results

GraphQL query returning duplicate results Question: 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 user …

Total answers: 1

Testing subscriptions using graphene.test in Python Graphene

Testing subscriptions using graphene.test in Python Graphene Question: What is the idiomatic approach for testing subscriptions in graphene-python? It seems that the client.execute option in graphene.test is only appropriate for Query testing. P.S. There is a subscription execution example in the documentation but it does not seem to be part of the testing library (https://docs.graphene-python.org/en/latest/execution/subscriptions/). …

Total answers: 2

Best way to construct a GraphQL query string in Python

Best way to construct a GraphQL query string in Python Question: 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 makes injecting …

Total answers: 4

Graphene/GraphQL find specific column value

Graphene/GraphQL find specific column value Question: For some reason, I can’t figure out how to simply find a specific piece of data in my SQLAlchemy database. In the graphene-python documentation it simply does this query to match the id (which is a string): book(id: “Qm9vazow”) { id title } Now here’s my Flask-Graphene-SQLAlchemy code for …

Total answers: 1

Mocking response for GraphQL query resolver from ServiceObject to prevent API calls in the UnitTests

Mocking response for GraphQL query resolver from ServiceObject to prevent API calls in the UnitTests Question: Let’s assume that I have the following service object: class Foo(object): def bar(self): return [‘foo’, ‘bar’] And this is the schema: import Foo class Query(graphene.ObjectType): bar = graphene.List(lambda: graphene.String) def resolve_bar(self, info): return Foo().bar() I am trying to test …

Total answers: 2

Error in graphQL python example code

Error in graphQL python example code Question: I am starting working on GraphQL and as I am from python background I am using GraphQL with Python. I followed the steps provided here Link but I am still facing issues. An error occurred while resolving field Query.hello Traceback (most recent call last): File “/usr/local/lib/python3.5/dist-packages/graphql/execution/executor.py”, line 311, …

Total answers: 3