Esempio n. 1
0
def mutate(client, mutation, selection):
    context = extract_context(selection)
    variables = context_to_variables(context)
    request_string = generate_mutation(mutation, variables)
    client('graphql', {
        'request_string': request_string,
        'variables': variables
    })
Esempio n. 2
0
def mutate(client, mutation, selection):
    """Issue a mutation over a network interface."""
    context = extract_context(selection)
    variables = context_to_variables(context)
    request_string = generate_mutation(mutation, variables)
    client('graphql', {
        'request_string': request_string,
        'variables': variables
    })
Esempio n. 3
0
def offline_mutate(mutation, selection):
    """Issue a mutation over the CLI or other offline interface."""
    context = extract_context(selection)
    variables = context_to_variables(context)
    for workflow in variables['workflow']:
        if mutation == 'play':
            cli_cmd('play', workflow)
        elif mutation == 'clean':  # noqa: SIM106
            cli_cmd('clean', workflow)
            # tui only supports single-workflow display ATM so
            # clean should shut down the program
            sys.exit()
        elif mutation in list_mutations(selection):  # noqa: SIM106
            # this is an "online" mutation -> ignore
            pass
        else:
            raise Exception(f'Invalid mutation: {mutation}')
Esempio n. 4
0
def list_mutations(selection):
    context = extract_context(selection)
    selection_type = list(context)[-1]
    return MUTATIONS.get(selection_type, [])