-
Notifications
You must be signed in to change notification settings - Fork 47
Input field Optional[OneToManyInput] is a required field in the resulting schema #9
Comments
Hey @gersmann , Hrm, I'm trying to replicate the issue here but it is working fine for me. The schema shows as not required and I can not send Can you provide more information regarding this? Like, the traceback itself, how are you doing the mutation, etc? |
@bellini666 you're right, not sure how that schema came to be, I didn't reproduce the problem correctly. It happens when inheriting a base type, this should reproduce it: @gql.django.input(ServiceInstance)
class ServiceInstancePartialInput(NodeInput):
id: gql.ID
service: Optional[OneToManyInput]
key: Optional[str]
@gql.django.input(Connector)
class ConnectorPartialInput(ServiceInstancePartialInput):
pass @gql.type
class ServiceMutation:
update_connector: ConnectorType = gql.django.update_mutation(ConnectorPartialInput) {
"data": null,
"errors": [
{
"message": "Field 'ConnectorPartialInput.service' of required type 'OneToManyInput!' was not provided.",
"locations": [
{
"line": 18,
"column": 25
}
],
"path": null
}
]
} Stack:
|
Noticed that inheritance behaves a bit strange in general, for instance if case a Django foreign key relationship is inherited, it is represented by the generic |
Hey @gersmann , You are calling your types
Don't know if I understood what you meant here... Could you provide an example of that too? |
This here replicates the original issue, also seems like it is inheritance-related: @gql.django.input(ServiceInstance)
class ServiceInstanceInput:
service: Optional[OneToManyInput]
@gql.django.input(Connector)
class ConnectorInput(ServiceInstanceInput):
updated_at: gql.auto
@strawberry.type
class Mutation:
create_service_instance: ServiceInstanceType = gql.django.create_mutation(ServiceInstanceInput)
create_connector: ConnectorType = gql.django.create_mutation(ConnectorInput) |
Hey @gersmann , Think I found the issue. Should be fixed in the release I'm doing right now. Please reopen this issue if it is not |
@bellini666 Thanks a lot. |
Not sure if this is expected behaviour, but if I define an input type like this:
The resulting schema marks 'service' as required field:
I can pass an empty object into service, sinceset
is not required, but I'd expectservice
to be not required instead.Edit: the schema allows for it, but if I do that the mutation fails.
The text was updated successfully, but these errors were encountered: