• This method will generate an array of mutation documents based on the changes between the original and the current values. It will detect the added and removed items using the key and will call the generateCreateMutation, generateDeleteMutation, generateUpdateMutation for each of the differences. The methods are expected to return the GraphQL mutation call that needs to be executed to perform that adding or removing on the backend service.

    The method will return an array with all create and delete mutations that were created. The result can be used to wrap it into a GraphQL mutation like that:

    const mutation = `mutation MyArrayUpdate {
    ${generateArrayMutationsWithUpdates({
    current: [{id: 1, value: 'ONE'},{id: 2, value: 'TWO'},{id: 3, value: 'THREE'}],
    original: [{id: 1, value: 'ONE'},{id: 2, value: 'TWO'}],
    generateCreateMutation: createFn,
    generateDeleteMutation: deleteFn,
    generateUpdateMutation: updateFn,
    key: 'id'}).join('\n')}}
    }`

    Type Parameters

    • T

    Returns string[]

Generated using TypeDoc