Skip to content

Good example of graphene-django covering multiple FK and choice field[Question] #1177

Answered by zbyte64
MilanRgm asked this question in Q&A
Discussion options

You must be logged in to vote

Here's what a nested mutation might do:

class CreateBusinessModel(graphene.Mutation):
    class Arguments:
        input = BusinessModelInput(description="These fields are required", required=True)

    class Meta:
        description = "Creates a new business model with companies and brands"

    errors = graphene.String()
    business_model = graphene.Field(BusinessModelNode)

    @staticmethod
    def mutate(root, info, input=None):
        user = info.context.user
        if not user.is_authenticated:
            return CreateBusinessModel(errors='Please Login')
        company = models.Company.objects.create(owner=user,
                                                name=input.compa…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by zbyte64
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #527 on April 14, 2021 20:14.