Questions tagged [strawberry-graphql]

Questions related to usage of Strawberry, a Python Library for creating GraphQL APIs using type hints in Python.

50 questions
1
vote
1 answer

Mocking SQLAlchemy test within Strawberry/FastAPI

I'm working on creating unit tests for a FastAPI, Strawberry, and SQLAlchemy setup. The current API is working and returning data correctly, but I cannot figure out how to mock the underlying database for unit tests. Would love any help/guidance to…
sokeefe
  • 627
  • 12
  • 33
1
vote
1 answer

FAST API + Strawberry GraphQL PyTest Testing Error

I currently use Fast API GraphQL+ Strawberry with pytest to test graphql schema queries and mutations. But when running multiple tests it sends me an error. $ 'message': "'NoneType' object has no attribute 'send'", My Python file for conf…
SYED FAISAL
  • 495
  • 5
  • 8
1
vote
1 answer

Django Strawberry writing a mutation that includes a foreign key that creates multiple objects

I am trying to have a GraphQL mutation create the inputs for two Django models at once using strawberry. I checked the documentation here and there weren't any examples of how to do this. I have the following Django model: class…
ccsv
  • 8,188
  • 12
  • 53
  • 97
1
vote
1 answer

Using functools.wraps function with a little bit different argument list

I want to do something like this: def need_session(func): @wraps(func) def wrapper(*args, **kwargs): session = SessionLocal() try: func(session, *args, **kwargs) finally: session.close() I'm…
pooooky
  • 490
  • 2
  • 12
1
vote
1 answer

FastAPI + Strawberry GraphQL Filter Conditions

I am currently build microservice using FastAPI + Strawberry GraphQL. I want to expose filters for the models with and/or condition. For example, { Student(where:{and[{AgeGt: 15},{PercentageLt: 75}]}) { edges { node { Name …
Riyas
  • 268
  • 2
  • 11
1
vote
1 answer

GraphQL Query to return non-iterable

I'm using strawberry-graphql in python, and have a query that returns a list of User @strawberry.type class User: email: str name: str def get_user(): items = get_from_database() return items @strawberry.type class Query: …
1
vote
1 answer

Django Strawberry Graphql Bad request 'str' object has no attribute 'execute_sync'

So I have a simple django model class County(models.Model): '''County''' name = models.CharField(max_length=100, null=False, blank=False) class Meta: verbose_name_plural = "Counties" ordering = ['name'] def…
ccsv
  • 8,188
  • 12
  • 53
  • 97
1
vote
2 answers

Fastapi + Strawberry GraphQL

I'm currently building a microservice with fastapi. I want to expose my underlying data via graphql on an additional route. Direct integration from starlette has been deprecated so I tried to use one of the recommended packages strawberry. At the…
gistBatch
  • 68
  • 1
  • 9
0
votes
0 answers

is it possible to have a single subscription waiting for data from multiple sources using graphql strawberry?

I am expecting to get data from multiple sources via single subscription if the data is not available in the source yield empty response, for certain number of retries @strawberry.type class DataFromSources: source_1 : JSON source_2 :…
0
votes
1 answer

How to resolve models in CUD operations not on PK but on UUID?

The default CUD operation in srawberry_django identifies the model to be mutated by the model's id (the database's id column, which is the Primary Key). How can I change this behavior to point to a column's/model's UUID without overriding…
Lukasz Dynowski
  • 11,169
  • 9
  • 81
  • 124
0
votes
1 answer

Graphql: show Mysql DB in using graphql with python

I have a mysql table, which i want to represent using graphQL, I have tried something using ariandne, and i am able to get the rows. Now, I want to introduce functionality of where clause as well, One way could be to have a resolver for each column,…
0
votes
0 answers

error: Module "strawberry.scalars" has no attribute "JSON"

According to the strawberry documentation (https://strawberry.rocks/docs/types/scalars) the JSON scalar type is available in strawberry.scalars. But it throws an error when it is imported: error: Module "strawberry.scalars" has no attribute…
0
votes
0 answers

model node-relation in graphql api in python

in our neo4j database, "Device" node is connected to "DeviceFeature" node with one way relation called "has". I am trying to find an efficient way to model this in my graphql api. I am using Strawberry and FastAPI. The below code works but I guess…
0
votes
0 answers

Sqlalchemy - FastAPI with strawberry Relational Column MySQL

I am using FastAPI with strawberry connected to a MySQL database. I have a table called User that is related to a foreign key called IdState with the State table. I would like to know how I can integrate the relationship between my model and the…
0
votes
1 answer

AttributeError: module 'strawberry.experimental' has no attribute 'pydantic'

I recently upgraded to python 3.9.17 from 3.7.11 and changed poetry version to 1.3.2 . However I am getting errors when I am trying to run that application. I am using strawberry-gql too However I am getting AttributeError: module…