-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
expose this.props.relay.getVarialbes() to component #1868
Conversation
|
@josephsavona @yuzhi can you guys please have a look? |
this looks good! @kassens what do you think about it? |
@josephsavona @kassens @wincent @yuzhi I’d also like to have this feature 🙏 |
Thanks for this investigation! Could you speak a bit more to the use case? I'd like to better understand the purpose of this new API (additions to documentation in the PR would be appreciated as well). Part of the reason I ask is because I understand that |
thanks @leebyron for looking into it. |
Oh didn’t realize that was a blessed way to access the variables. I was under the impression that access to React’s context should be abstracted away where possible. In that light, would it make sense to redo this PR by just exposing the context’s variables from the Relay prop? |
I'm missing something here - I don't have a How do we get access to |
static contextTypes = {
relay: PropTypes.shape({
variables: PropsTypes.object,
}),
}, try this commit fixes some missing variables 1ce348a |
@leebyron I've checked the latest code and can verify that what else can we get from |
merged with latest. loop in @kassens as he is the author of having again. not urgent anymore but it's something nice to have in my view. |
@leebyron @sibelius This solves a lot of bugs with the current relay version. Is there a reason there isn't more of rush to get this merged / released? I'm also having an issue where a pagination container's fragmentVariables are the default ones instead of the current ones. Which I assume is yet another related bug. |
Accessing the context works great for finding variables that are defined on the That would allow one source of truth for determining the page size when fetching data (rather than having to define both in JS and GraphQL) |
If anyone has issues accessing
Also, import:
As per React > 15. The last bit is pretty important, as a lot of answers online will suggest using |
@ekosz I at least would very much appreciate that and would test it in our apps. |
I recently took a stab at updating this PR, but things changed significantly enough that this became more than dealing with mere merge conflicts. If anybody wants to take a stab at it or redo it, that would be much appreciated! |
Any plans or merging this or exposing the variables in an alternative way? |
Our general approach to this is to pass down query variables explicitly when we need them in components. Note that the local variables are already exposed by RefetchContainer and PaginationContainer - for example, I'm going to close this PR since there's a workaround. |
Hi there,
this PR is to address issue #1828 , #1984 , #1986
the key change is
because a
selector
always keep the correct/updated variables, so we should keep it as the source of true.a unit test has been added to verify this.
thanks