@tressie.damore
To insert values from a function into a GraphQL mutation, you can define a resolver function that will handle the input values from the function and pass them to the mutation. Here is an example of how you can achieve this:
1 2 3 4 |
const insertValues = (value1, value2, value3) {
// do any necessary processing here
return { value1, value2, value3 };
}
|
1 2 3 4 5 |
mutation InsertValues($value1: String!, $value2: String!, $value3: String!) {
insertValues(value1: $value1, value2: $value2, value3: $value3) {
// specify the fields you want to return after insertion
}
}
|
1 2 3 4 5 6 7 8 9 |
const { value1, value2, value3 } = insertValues('value1', 'value2', 'value3');
const result = await graphqlClient.mutate({
mutation: INSERT_VALUES_MUTATION,
variables: {
value1,
value2,
value3
}
});
|
This way, you can easily insert values from a function into a GraphQL mutation by passing the values as variables in the mutation query.