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

Create option to force queries to use local store #225

Closed
siegesmund opened this issue May 18, 2016 · 5 comments
Closed

Create option to force queries to use local store #225

siegesmund opened this issue May 18, 2016 · 5 comments
Assignees

Comments

@siegesmund
Copy link

There are instances where it's advantageous to prevent a query from trying to fetch data from the server. For example, if two components depend on the same data, and are both connected to the same query, both queries will fetch data from the server if neither query has completed before the other is executed. In instances like these, finer grained control would be useful.

In reference to: https://forums.meteor.com/t/apollo-query-patterns-with-react-redux/23347/5

@abhiaiyer91
Copy link
Contributor

@stubailo If we have already fetched data via a query, should this data be able to be connected in non-apollo containers via mapStateToProps?

@stubailo
Copy link
Contributor

I think this can be a pretty small feature:

(1) A new option to query and watchQuery, maybe called something like noFetch, which tells Apollo to not do any fetches at all for this query, and simply return what it can find in the store at the time.

This will enable people using Apollo connect to use data from the store in mapQueriesToProps without actually fetching anything.

@abhiaiyer91 it seems what you're talking about is a bit different, and I'd say it warrants a separate issue, which is the ability to load Apollo data from the Redux store directly without going through ApolloClient? I guess I'm not really sure why people would need to do that, since eventually the Apollo connect will be much more optimized than custom loading in the regular Redux connect. At the very least you'll need to use reselect in very clever ways to avoid re-renders.

@stubailo
Copy link
Contributor

I guess I'm not really sure why people would need to do that, since eventually the Apollo connect will be much more optimized than custom loading in the regular Redux connect.

Just found a reason - other redux wrappers like Redux Form.

@siegesmund
Copy link
Author

Yea, I'm glad you did ;). I've been looking for a better answer than 'because it feels right to me.'

To me, it seems natural that we should be able to blend apollo seamlessly into Redux. One of the major design points of Redux is the single state container. With Apollo/Redux we now have a nested state container within a container, that can no longer be easily directly accessed. The Apollo object is now available sort of globally via redux, and we can use it to inject data into our components, but we are forced to trade the control, precision and power of redux for the intelligence and brevity of code of Apollo.

Right now, I am using Apollo client in two ways: 1) I am using Apollo client and writing all of the redux types, actions, reducer etc. In other, words, I'm not using the Redux integration. 2) For some components, I'm trying to use the Apollo/Redux integration. Being able to access Apollo data in the store would largely remove this distinction.

@stubailo
Copy link
Contributor

Filed a new issue here: #227

jbaxleyiii pushed a commit that referenced this issue Oct 17, 2017
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants