I have a Query
type in my schema that defines some custom resolvers and uses strawberry_django.field
/strawberry_django.node
without providing resolver functions.
@strawberry_django.type(SomeModel)
class SomeType:
id: auto
name: auto
@strawberry.type(name='Query')
class Query:
some_type_query: SomeType = strawberry_django.field()
@strawberry_django.field()
def custom_resolver(self) -> bool:
return True
I want to return a Query
along with the mutation result, enabling the user to fetch whatever data they need in a single request. However, when I initialize a Query object, I must provide arguments.
@strawberry.type
class MutationPayload:
some_type: SomeType
@strawberry_django.field(
def query(self) -> Query:
return Query()
@strawberry.type
class Mutation:
@strawberry_django.mutation()
def mutation_resolver(self) -> MutationPayload:
some_model = SomeModel.objects.create(name="test")
return MutationPayload(some_type=some_model)
{
"data": null,
"errors": [
{
"message": "Query.__init__() missing 1 required keyword-only argument: 'some_type_query'",
"locations": [
{
"line": 7,
"column": 5
}
],
"path": [
"mutationResolver",
"query"
]
}
]
}
Is it possible to initialize the Query
type without providing all the arguments? Or is there an easy way to provide the arguments to the query?
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too