I try follow https://www.howtographql.com/graphql-python/3-mutations/ but got error
"graphql.error.located_error.GraphQLLocatedError: mutate() got an unexpected keyword argument 'url' "
Code like:
class CreateLink(graphene.Mutation):
id = graphene.Int()
url = graphene.String()
description = graphene.String()
#2
class Input:
url = graphene.String()
description = graphene.String()
#3
@staticmethod
def mutate(root, input, context, info):
link = Link(
url=input.get('url'),
description=input.get('description')
)
link.save()
return CreateLink(
id=link.id,
url=link.url,
description=link.description,
)
class Mutation(graphene.AbstractType):
create_link = CreateLink.Field()
When try run:
mutation{
createLink(
url:"https://github.com/",
description:"XXXXX"
){
id
url
description
}
}
Got error
See if you're using the v2 of Graphene... It has a change with the Input class. Try replacing "Input" with "Arguments":
Mutation.Input is now deprecated in favor of using Mutation.Arguments (ClientIDMutation still uses Input).
Before:
class User(Mutation):
class Input:
name = String()
With 2.0:
class User(Mutation):
class Arguments:
name = String()
Also mutate has change:
https://github.com/graphql-python/graphene/blob/master/UPGRADE-v2.0.md
Read the 2.0 update docs and you'll be fine!
The tutorial needs to be updated :( I'll try to look into that ASAP!
The tutorial is updated! This can be closed 馃帀
Most helpful comment
See if you're using the v2 of Graphene... It has a change with the Input class. Try replacing "Input" with "Arguments":
Mutation.Input
Mutation.Inputis now deprecated in favor of usingMutation.Arguments(ClientIDMutationstill usesInput).Before:
With 2.0:
Also mutate has change:
https://github.com/graphql-python/graphene/blob/master/UPGRADE-v2.0.md
Read the 2.0 update docs and you'll be fine!