Skip to content

Multiple Mutaion classes in schema #333

Closed
@mzohaibqc

Description

@mzohaibqc

I have multilpe services and each have lot of mutations like

class SnMutations(graphene.ObjectType):
    # Event mutations
    create_event = CreateEvent.Field()
    update_event = UpdateEvent.Field()
    delete_event = DeleteEvent.Field()

    # Venue mutations, Meetup does not allow to update a venue. Also it does not make sense.
    create_venue = CreateVenue.Field()

    # EventOrganizer mutations
    create_event_organizer = CreateEventOrganizer.Field()
    update_event_organizer = UpdateEventOrganizer.Field()
    delete_event_organizer = DeleteEventOrganizer.Field()

    # Authorization mutations
    refresh_token = RefreshToken.Field()
    add_social_network_credentials = AddSocialNetworkCredentials.Field()

and

class CandidateMutation(graphene.ObjectType):
    create_candidate = CreateCandidate.Field()
    update_candidate = UpdateCandidate.Field()

and more

Now I want to create schema with all these mutations but I want to send query for each mutation under a specific key like sn_mutations and candidate_mutations for candidate service.

mutation {
    sn_mutations {
         create_event (some values) {

        }
    }
}

But I can only pass a single class in schema.

schema = Schema(query=Query, mutation=SnMutation, auto_camelcase=False)

I tries graphene.AbstractType and Inherited main Mutation class from all other Mutation class but in this way I can not divide mutation for every service in query under a specific key like sn_mutations and candidate_mutations.
Any help is most appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions