INNER CODE UNIT · Python

CreateBook

phalt/django-api-domains · example_domain/apis.py:31

class CreateBook(relay.ClientIDMutation):
    class Input:
        book_name = graphene.String(required=True)
        author_id = graphene.ID(required=True)

    book = graphene.Field(BookEntity)

    @classmethod
    def mutate_and_get_payload(cls, root, info, **input):
        new_book = BookService.create_book(
            name=input.get('book_name'),
            author_id=input.get('author_id')
        )
        return BookEntity(
            name=new_book['name'],
            author_name=new_book['author_name'],
        )

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…