| 49 | |
| 50 | |
| 51 | class CreateLink(graphene.Mutation): |
| 52 | id = graphene.Int() |
| 53 | url = graphene.String() |
| 54 | description = graphene.String() |
| 55 | posted_by = graphene.Field(UserType) |
| 56 | |
| 57 | class Arguments: |
| 58 | url = graphene.String() |
| 59 | description = graphene.String() |
| 60 | |
| 61 | def mutate(self, info, url, description): |
| 62 | user = info.context.user or None |
| 63 | |
| 64 | link = Link( |
| 65 | url=url, |
| 66 | description=description, |
| 67 | posted_by=user, |
| 68 | ) |
| 69 | link.save() |
| 70 | |
| 71 | return CreateLink( |
| 72 | id=link.id, |
| 73 | url=link.url, |
| 74 | description=link.description, |
| 75 | posted_by=link.posted_by, |
| 76 | ) |
| 77 | |
| 78 | |
| 79 | class CreateVote(graphene.Mutation): |