0

I can't find out how to update table after deleting row. Apollo-server is used in backend and relay for client. I'm trying to use NODE_DELETE but I don't know what I'm doing wrong

this is delete mutation

    const mutation = graphql`
mutation DeleteAdMutation(
    $id: ID!
) {
    deleteEvent(
        id: $id
    )
    {
        deletedId
    }
}`;

export const DeleteEvent = (input) => {
return new Promise((resolve, reject) => {
    commitMutation(
        environment,
        {
            type: 'NODE_DELETE',
            deletedIDFieldName: 'deletedId',
            mutation,
            variables: input,
        }
    )
});};

deletedId returned successfully but nothing changes in table

table query:

 const GetADayTours = graphql`
query GetADayToursQuery(
    $type: String!,
    $page: Int!,
    $row: Int!,
) {
    getADayTours(
        type: $type,
        page: $page,
        row: $row,
    ) {
        page
        row
        total
        data{
            ...on aDayTour{
                ...Row_row
            }
        }
    }
}`;
  export default GetADayTours;

and here is row fragment:

createFragmentContainer(RowComponent
, {
    row: graphql`
        fragment Row_row on aDayTour {
            _id
            id
            title
        }
    `,
});
Reza Sam
  • 1,264
  • 2
  • 14
  • 29

1 Answers1

0

You have to add ConnectionKey for paginated records while querying data

refer this

https://relay.dev/docs/en/pagination-container.html#connection, on how to add connection while querying.

And after that when when you want to delete using nodeId, you have to use connectionHandler from 'relay-runtime':

https://relay.dev/docs/en/relay-store#connectionhandler