8000 fix: Fix the mutation problem · graphql-python/swapi-graphene@5bbb8b3 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5bbb8b3

Browse files
committed
fix: Fix the mutation problem
1 parent 9d6ba16 commit 5bbb8b3

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

starwars/schema.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ def resolve_viewer(self, *args, **kwargs):
178178
return self
179179

180180

181-
class CreateHero(graphene.ClientIDMutation):
181+
class CreateHero(graphene.Mutation):
182182

183183
class Input:
184184
name = graphene.String(required=True)
@@ -187,10 +187,9 @@ class Input:
187187
hero = graphene.Field(Hero)
188188
ok = graphene.Boolean()
189189

190-
@classmethod
191-
def mutate_and_get_payload(cls, input, info):
192-
name = input.get('name')
193-
homeworld_id = input.get('homeworld_id')
190+
def mutate(self, args, context, info):
191+
name = args.get('name')
192+
homeworld_id = args.get('homeworld_id')
194193
try:
195194
homeworld_id = int(homeworld_id)
196195
except ValueError:
@@ -208,10 +207,10 @@ def mutate_and_get_payload(cls, input, info):
208207

209208

210209
class Mutation(graphene.ObjectType):
211-
create_hero = graphene.Field(CreateHero)
210+
create_hero = CreateHero.Field()
212211

213212

214213
schema = graphene.Schema(
215214
query=Query,
216-
mutation=Mutation,
215+
mutation=Mutation
217216
)

0 commit comments

Comments
 (0)
0