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

When using apollo-ios-pagination, there is an issue where data is not accurately updated when mutations occur. #3331

Closed
rlsmd9 opened this issue Feb 8, 2024 · 1 comment · Fixed by apollographql/apollo-ios-dev#260
Labels
question Issues that have a question which should be addressed

Comments

@rlsmd9
Copy link

rlsmd9 commented Feb 8, 2024

Question

When the cached value of a paginated query changes, the onFetch method of AsyncGraphQLQueryPager is invoked via a watcher. It seems that during this process, the variables are utilized as keys in the nextPageVarMap dictionary. If a key already exists, the data is updated; otherwise, a new page is added.

The issue lies in the fact that the Variables of a GraphQLOperation are represented as a dictionary, and the values of this dictionary are used as keys. For instance, with a query like:

Query(
    filter: .init(
        mine: true,
        query: query,
        orderType: latest
    ),
    first: 15,
    after:123123)

the variables can result in various keys such as:

  • [[mine: true, query: “123213”, orderType: “latest”], 15, 123123]
  • [15, [mine: true, query: “123213”, orderType: “latest”], 123123]
  • [15, 123123, [mine: true, query: “123213”, orderType: “latest”]]

Converting the Variables dictionary of the Query into an array does not maintain consistent ordering, which leads to the inability to identify the same page consistently, thus resulting in the addition of new pages instead of updating existing ones.

If you are aware of a solution to this issue, please share!

@rlsmd9 rlsmd9 added the question Issues that have a question which should be addressed label Feb 8, 2024
@Iron-Ham
Copy link
Contributor

Iron-Ham commented Feb 9, 2024

Hi @ralph-101-dev!
You're 100% correct. I'll open up a PR addressing that shortly. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Issues that have a question which should be addressed
Projects
None yet
2 participants