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

Add "reduxRootSelector" parameter to the ApolloClient contructor #631

Conversation

vovacodes
Copy link
Contributor

This feature was discussed with @stubailo on the Slack channel

@stubailo
Copy link
Contributor

For backwards compatibility, can we still accept a reduxRootKey option, and simply convert that into a function? It can also print a warning telling people to upgrade to the new option.

Perhaps we can remove the backcompat in 1.0.

@abhiaiyer91
Copy link
Contributor

Would we be against having reduxRootKeyOrSelector where the user can optionally provide a selector function? I'm not sure how many users want to override the rootkey behavior with functions? Is this a lot?

@stubailo
Copy link
Contributor

@abhiaiyer91 I was thinking it would be simpler to just have one way to pass it.

But I would be on board with a hybrid option. I think calling it reduxRootSelector is fine, since you can imagine that passing a string as the selector would just select that key.

@vovacodes
Copy link
Contributor Author

@stubailo @abhiaiyer91 We cannot actually remove the reduxRootKey option, because in case client constructs the store by itself it needs to know where to put the state in, i.e. what key to use and unfortunately you cannot extract that information from the selector.

@jbaxleyiii
Copy link
Contributor

@wizardzloy I'll need to update this in react-apollo as well

@stubailo
Copy link
Contributor

in case client constructs the store by itself it needs to know where to put the state in

Is there any reason you would care what that key is called if you didn't create the store yourself? Since then Apollo is the only thing using that store.

@vovacodes
Copy link
Contributor Author

@stubailo fair enough, if you don't see a scenario for that, I don't see it either. Let's then proceed with the reduxRootSelector option that can be either a string or a function, while preserving the reduxRootKey with a warning message. I'll implement the changes.

@jbaxleyiii sure, I'll open a PR to react-apollo once this one is merged, would it be ok?

@stubailo
Copy link
Contributor

This looks great, we should merge it ASAP!

@vovacodes vovacodes force-pushed the feature/add-redux-root-selector-option branch from 75fb67d to 037da2e Compare September 14, 2016 09:31
@vovacodes
Copy link
Contributor Author

@stubailo I've updated the PR according to your comments

@stubailo stubailo self-assigned this Sep 16, 2016
@stubailo
Copy link
Contributor

Merging here: #662

@stubailo
Copy link
Contributor

Done!

@stubailo stubailo closed this Sep 17, 2016
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 18, 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

Successfully merging this pull request may close these issues.

4 participants