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

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

Open
taybenlor opened this issue Jun 7, 2021 · 0 comments
Open

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

taybenlor opened this issue Jun 7, 2021 · 0 comments

Comments

@taybenlor
Copy link

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.

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

No branches or pull requests

1 participant