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 re-fetch query watchers #509

Merged
merged 3 commits into from
Jun 7, 2017

Conversation

sav007
Copy link
Contributor

@sav007 sav007 commented Jun 3, 2017

Re-fetch query watchers after mutation completed
Refactor ApolloTracker.

Closes #452

Re-fetch query watchers after mutation completed
Refactor ApolloTracker.

Closes apollographql#452
});
} else { //noinspection unchecked
responseCallback.onResponse(response.parsedResponse.get());
private void refetchQueryWatchers() {
Copy link
Contributor

@BenSchwab BenSchwab Jun 4, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although strange, should this be refetchRefetchQueryWatchers?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry what do you mean?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'refetchQueryWatchers` sort of makes it seem like we will be refetching all query watchers - but really we are refetching the set of "refetch" query watchers, right?

It's an internal method, so not a big deal at all.

queryFetcher.get().refetchAsync(new QueryFetcher.OnFetchCompleteCallback() {
@Override public void onFetchComplete() {
//noinspection unchecked
originalCallback.onResponse(response.parsedResponse.get());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be safe to not block the original call on the refetch queries? I can see the argument for both ways, ideally if it blocked or not would be user configurable.

Additionally, the actually refetch routine seems to be serially executed. Maybe we should investigate just dumping all the refetch querries into one graphql query? Although is may complicate query whitelisting.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should investigate just dumping all the refetch querries into one graphql query?

Yeah that will be awesome, we def need to explore this, I see though as it won't be trivial. At the same time we can explore overall merging queries (smth like throttling ) into one call.

Copy link
Contributor

@BenSchwab BenSchwab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM overall. Have some concerns with the fact that refetch queries seem to block the main response, although I can see why that may be desired in some use cases.

Also, do we need to guard against an infinite loop of refetch queries? (Two refetch queries reference each other and ping pong back and forth refetching)

@sav007
Copy link
Contributor Author

sav007 commented Jun 4, 2017

@BenSchwab

Also, do we need to guard against an infinite loop of refetch queries? (Two refetch queries reference each other and ping pong back and forth refetching)

That should not be the case, as refetch queries names can be set only for ApolloMutationCall. At the same time you can't watch ApolloMutationCall only query can be watched. So we are safe here.

Would it be safe to not block the original call on the refetch queries? I can see the argument for both ways, ideally if it blocked or not would be user configurable.

Yeah I thought about this and don't have strong opinion on that so not sure what the right way.

@stubailo
Copy link
Contributor

stubailo commented Jun 5, 2017

Maybe we should investigate just dumping all the refetch queries into one graphql query? Although is may complicate query whitelisting.

A better approach would be to use transport batching probably (sending multiple documents/query IDs in one request), that way you can still whitelist, but they can be sent in one request and batched on the server.

@sav007
Copy link
Contributor Author

sav007 commented Jun 7, 2017

@digitalbuddha any comments?

@sav007 sav007 merged commit bf14d3b into apollographql:master Jun 7, 2017
@sav007 sav007 deleted the feature-452/refetch-watchers branch June 7, 2017 18:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants