Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement automatic data updates for adding a node to arrays and removing from arrays #1

Open
klis87 opened this issue Mar 23, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@klis87
Copy link
Owner

klis87 commented Mar 23, 2023

Currently for mutations like ADD_BOOK, or REMOVE_BOOK, there are no automatic updates - without some extra hints, the library cannot know which arrays to update and how.

It should be possible though with some extra hints.

@klis87
Copy link
Owner Author

klis87 commented Apr 4, 2024

Example how we could mark explicitly arrays which could be automatically updated:

const responseWithArray = {
  x: 1,
  list: {
    type: 'LIST_1',
    nodes: [{ id: 1, value: 'x' }],
  },
};

Examples how responses hints could look like:

// remove objects from all arrays
{ id: 1, _remove: '*' }

// append object to LIST_1
{ id: 1, _append: 'LIST_1' } 

// append object to LIST_1 and LIST_2
{ id: 1, _append: ['LIST_1', 'LIST_2'] } 

// prepend object to LIST_1 and LIST_2
{ id: 1, _prepend: [LIST_1', 'LIST_2'] } 

// move object from LIST_1 to LIST_2
{ id: 1, _remove: 'LIST_1', _append: 'LIST_2' } 

// replace object with id 1 with object with id 2
[{ id: 1, _remove: 'LIST_1' }, { id: 2, _append: 'LIST_1' }]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant