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

Настройки для Query чтобы рефетч срабатывал с ее последними параметрами #470

Open
xaota opened this issue Apr 9, 2024 · 1 comment
Labels
scope:core type:enhancement New feature or request
Milestone

Comments

@xaota
Copy link

xaota commented Apr 9, 2024

кейс

const query = createQuery(...);
const mutation = createMutation(...);

query.start({ param: 1 });

update(query, {
  on: mutation,
  by: {
    success: () => ({
      error: null,
      refetch: true // вот сюда надо передать { params: { param: 1 } }, и в более сложном случае требуется много писанины
    })
  }
});

mutation.start()

в этом случае query стартует после мутации без параметров, что не есть удобно

Чтобы это поведение изменить надо передавать в refetch параметры, а далеко не всегда есть удобный доступ к ним (на самом деле просто писанины много лишней)

Предложение

при создании query добавить настройку типа keepParamsOnRefetch чтобы если происходит вызов refetch были использованы последние параметры, с которыми вызывалась query.start

пример

const query = createQuery({
  ...,
  keepParamsOnRefetch: true
});
const mutation = createMutation(...);

query.start({ param: 1 });

update(query, {
  on: mutation,
  by: {
    success: () => ({
      error: null,
      refetch: true // вызовется с {param: 1}
    })
  }
});

mutation.start()

// дальше код условный - не претендует на реалистичность, допустим что все синхронно
mutation.start() // после мутации query будет снова вызвана с { param: 1 }

query.start({ param: 2 })

mutation.start() // после мутации query будет вызвана с { param: 2 }
@xaota
Copy link
Author

xaota commented Apr 9, 2024

Будет неплохо комбить с #465

@igorkamyshev igorkamyshev added type:enhancement New feature or request scope:core labels Apr 10, 2024
@igorkamyshev igorkamyshev added this to the v1.0 milestone Apr 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope:core type:enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants