Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Improve docs about integration with redux. Show how to access apollo store. #452

Closed
brunoreis opened this issue Feb 6, 2017 · 3 comments

Comments

@brunoreis
Copy link

Apollo is excellent to work with business logic on the server. But, I'm facing some blocker questions on how to do simple business logic on the client because the only provided method I could find to query apollo store is the graphql wrapper injection of props.

What's the problem I'm facing?

In my reducers I need to have access to data queried by apollo, because they are needed to fulfil that action's purpose. I'm not gonna change apollo's store, because it's clear to me it should not be done. But, I need to use the data that is in there to be able to make some calculations and change my app's store.

Should I query apollo's store and just grab data from there? It feels to me that this could break some contracts. It's clear that apollo has a nice way to query this data and return it in a structured (denormalized) format.

Are there methods available to query apollo's store? I fell that graphql-anywhere is probably a good tool for that, but I could not find how to query the store using it. I also think that we should be able to get the exact query result at that place (inside a reducer) and receive the same structure that is injected by the graphql wrapper.

The structured data injected in the component is excellent for rendering purposes, but I also need this data on the reducers. Today as this data is only available inside components, it kink of imposes a bad pattern (IMHO) that is to keep business logic in there.

So, this are my concerns. I'd like to hear the solutions and options available to do this.

After that, I can come up with a PR on the docs (here I guess:http://dev.apollodata.com/react/redux.html) with the result of this discussion.

@calebmer
Copy link
Contributor

calebmer commented Feb 7, 2017

This is definitely something we are discussing, and we plan to add read and write functions in the near future to support this case.

There are a few issues tracking this on the apollo-client repo such as apollographql/apollo-client#1224

@brunoreis
Copy link
Author

Thanks. I did not see the need for the write yet, but sure did for the read. I'll see if I have something to collaborate on that discussion tomorrow.

@jbaxleyiii
Copy link
Contributor

read and write are implemented 💯

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

3 participants