Skip to content

Prevent occasional error of SubSelectionRequiredΒ #2001

@vicary

Description

@vicary

Summary

For GraphQL fields that allows sub-selections, where the cache contains an empty array, or nulls for nullable object fields, it may block the proxy from capturing selections further down the tree.

A previous attempt #1757 reduces the effect, but it doesn't not prevent the issue in use cases with multiple concurrent fetches.

Steps to reproduce

These are user reported scenarios:

  1. resolve() on paginated queries may trigger this after one of the result set contains a null object under an array.
  2. useQuery() in React may fail when a new fetch is triggered during an active fetch, where the response of the first fetch clears selections before the second one has a chance to cache it.
  3. createQuery() in Solid includes an attempt to fix this, but it triggers another issue where the last promise fails to resolve, locking the UI in a loading/suspended state.

Expected Results

When new fetches are triggered,

  1. responses from previous fetches should update the cache
  2. responses from previous fetches should not trigger cache listeners
  3. responses from previous fetches should not trigger the onNext callback in subscribe
  4. response of the last fetch should update the cache, notify cache listeners and trigger UI updates downstream.

Additional Information

#1758 will attempt to cover racing condition on cache updates and selection clearing for concurrent fetches.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions