Skip to content

Support for fetch reference (e.g. for Relay) #90

@taybenlor

Description

@taybenlor

Hi, I love the getData and useResource pattern, the DX would be really nice for straight fetching data.

Relay doesn't set up its API in a way that would work nicely with this approach. It has two main functions:

// In your routes
const queryRef = loadQuery(/* ... */);

// In your component
const { data } = usePreloadedQuery(queryRef, /*... */);

Instead of using a promise to figure out if the fetch is complete, it uses a reference that acts as a handle on the request. This would work okay (if a bit strange) with getData and useResource, I could just ignore the loading and error statuses. Except that the queryRef needs to be actively disposed when it is no longer displayed.

Potentially a solution would be to add a more customisable get and dispose combo of options to the router config.

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