Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upClient scoped query recyclers (#513) #876
Conversation
This comment has been minimized.
This comment has been minimized.
meteor-bot
commented
Jul 21, 2017
@rcoedo: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Meteor Contributor Agreement here: https://contribute.meteor.com/ |
This comment has been minimized.
This comment has been minimized.
@rcoedo thank you for this PR! I'll take a look at it today and provide some feedback! |
This comment has been minimized.
This comment has been minimized.
@rcoedo the code for this looks great! I'll see if I can write up a test scenario for you with some guidance of how to test! |
jbaxleyiii
self-assigned this
Jul 25, 2017
This comment has been minimized.
This comment has been minimized.
Thanks for reviewing it @jbaxleyiii I've been thinking about this isssue and having these WeakMaps all around as global application state seems kind of hackish. It works but I think there has to be a better solution. Maybe a better approach would be to have a any thoughts? |
This comment has been minimized.
This comment has been minimized.
@rcoedo I do think adding it to the context could be good, but I'm nervous about updating causing rerenders based on context updates. By keeping it out of the tree, we don't risk updates. I'd rather not introduce new providers (at least to the external API). What would the updating look like? Could we write a test to ensure it wouldn't rerender? I do think having it on the context would be great btw! |
This comment has been minimized.
This comment has been minimized.
I think it wont cause rerenders since the context will only hold a reference to a Map and that reference will never change. The provider I propose is internal only, since we don't want to leak the recycler implementation details. For safety, in that provider we could implement shouldComponentUpdate as a function that always return false. |
This comment has been minimized.
This comment has been minimized.
@rcoedo that sounds great! Would you update this PR to move to that version? |
rcoedo
force-pushed the
rcoedo:master
branch
3 times, most recently
from
80c53c2
to
8fea657
Aug 8, 2017
rcoedo
force-pushed the
rcoedo:master
branch
from
8fea657
to
c0a6b22
Aug 8, 2017
This comment has been minimized.
This comment has been minimized.
@jbaxleyiii I updated the PR. Current tests are passing and I manually tested it out in my playground and it seems to be working. If you feel like we need more testing I'd really appreciate some guidance, there are a lot of use cases that I probably miss since I'm not experienced with apollo or react-apollo. Thanks! |
This comment has been minimized.
This comment has been minimized.
@rcoedo YAY! This is so great! I'm going to do a release to address some flow type issue then take a look this week! Thank you!! |
This comment has been minimized.
This comment has been minimized.
@rcoedo I think this is a great start. We can come back and increase testing later but I'm going to merge and release this |
jbaxleyiii
merged commit 93ba6ee
into
apollographql:master
Aug 13, 2017
This comment has been minimized.
This comment has been minimized.
@jbaxleyiii Thanks for the kind words I've been thinking and with this implementation the recyclers will be reset when the client changes in the ApolloProvider. I'm not sure how are users using this. Is it common to bounce from client to client in the same application? If this is the case, we may need to keep those recyclers alive as well, and use a Map<ApolloClient, Map<Component, QueryRecycler>> instead to store the state. |
rcoedo commentedJul 21, 2017
This PR addresses the issue #513. I used a WeakMap as suggested in this conversation #462 (comment), but I'm not sure if we should polyfill WeakMap.
I tried the code linking the package to my playground and it works, but I'm a bit lost with the test structure of the project and I don't really know how to write a test for this feature.
Also I'm also quite new to Apollo and I've never touched Typescript before so I really appreciate all the feedback you can give😄