You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to update a django model that has a one to many relation with the model that has the mutation. I know this is possible with queries and also with graphene.Mutation mutations using class Arguments.
i am currently using graphene.relay.ClientIDMutation and I would like to know if its possible to have a dynamic sized class of inputs as an argument for the mutation.
here is a representation of inputs(array) I want to work with,
I'm having an issue with the described method of using an input type of List(MyInputType).
Roughly, my code looks like this:
classMyInputType(graphene.ObjectType):
id=graphene.String(required=True)
credentials=graphene.JSONString(required=True)
classMyMutation(graphene.Mutation):
classArguments:
my_types=graphene.List(MyInputType, required=True)
asyncdefmutate(root, info, my_types):
# Do some stuff
It fails resolving the mutation fields:
File "/Users/icebreaker/Projects/graphene-test/lib/python3.9/site-packages/graphql/type/definition.py", line 745, in fields
raise TypeError(f"{self.name} fields cannot be resolved. {error}")
TypeError: MutationRoot fields cannot be resolved. Argument type must be a GraphQL input type.
Moreover, changing the graphene.List to graphene.Argument, raises the same exception.
I have tried to replace the MyInputType with a built-in graphene type: my_types = graphene.List(graphene.String, required=True), and the error did not appear.
I assume it's an issue with supporting custom ObjectType classes in mutation arguments.
@samarthkathal , @jkimbo , Just figured it out.
Custom input types should inherit from graphene.InputObjectType instead of graphene.ObjectType.
Changed to MyInputType(graphene.InputObjectType and it worked like a charm
I want to update a django model that has a one to many relation with the model that has the mutation. I know this is possible with queries and also with
graphene.Mutation
mutations usingclass Arguments
.i am currently using
graphene.relay.ClientIDMutation
and I would like to know if its possible to have a dynamic sized class of inputs as an argument for the mutation.here is a representation of inputs(array) I want to work with,
The text was updated successfully, but these errors were encountered: