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

Query merging at top level #277

Merged
merged 25 commits into from
Jun 17, 2016
Merged

Query merging at top level #277

merged 25 commits into from
Jun 17, 2016

Conversation

Poincare
Copy link
Contributor

@Poincare Poincare commented Jun 11, 2016

This PR (originally part of PR #266) implements query merging at the top level. It provides functions that can take multiple queries and place them under the same query while aliasing the names within the AST to prevent collisions. The point of doing this is to implement query batching without requiring any changes to the server (see issue #164).

The CHANGELOG has not been updated since this is not a user-facing change (yet).

TODO:

  • Update CHANGELOG.md with your change
  • Make sure all of the significant new logic is covered by tests
  • Rebase your changes on master so that they can be merged easily
  • Make sure all tests and linter rules pass

@Poincare Poincare mentioned this pull request Jun 11, 2016
4 tasks
import cloneDeep = require('lodash.clonedeep');

// A handler that takes a selection, variables, and a directive to apply to that selection.
export type DirectiveResolver = (selection: Selection,
Copy link
Contributor

Choose a reason for hiding this comment

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

This alignment is pretty odd - we don't do it anywhere else in the code this way.

@helfer
Copy link
Contributor

helfer commented Jun 14, 2016

Are the changes in QueryManager.ts related to this PR? I was under the impression that the mangling should be completely managed by the network interface.

Also, related to the previous question, does this PR introduce the batching ability in Network Interface? If so how does it relate to the batching PR?

It looks like directives.ts got into this PR by accident, so maybe that's the case for the other stuff, too?

I think the only files that should be in there are queryMerging.ts and tests/queryMerging.ts, along with the necessary changes in tests.ts, right?

@Poincare
Copy link
Contributor Author

The changes in QueryManager.ts are needed for this PR because this PR needs the Request object to deal with Document instances rather than query strings. This PR adds a method that can turn a regular NetworkInterface into a BatchedNetworkInterface by introducing query composition. This can't be moved into the batching PR because it uses basically all of the functionality introduced in queryMerging.ts.

The directives.ts should not be part of this PR - I will get rid of that. Other than that, the files that have been changed should be part of this PR as far as I understand.

@helfer
Copy link
Contributor

helfer commented Jun 15, 2016

Would it be possible to make all the batching related changes in the batching PR, and then rebase this PR on top of that one? Or is the batching PR made on top of this one?

@Poincare
Copy link
Contributor Author

The batching PR is made on top of this one. If this one can is merged before the batching one, we can just apply the batching PR on top of this PR on master.

@Poincare
Copy link
Contributor Author

Removed src/directives.ts. The files now included are the ones that are relevant to query merging.

@helfer
Copy link
Contributor

helfer commented Jun 15, 2016

Ok, that's fine. I would have thought that logically this PR comes on top of the batching one (because it implements a particular way of batching), but it doesn't matter all that much, as long as the end-result is what we need.

}
);
});

Copy link
Contributor

@helfer helfer Jun 15, 2016

Choose a reason for hiding this comment

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

Why is this test no longer needed? Is this related to query merging?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since we now use the query document for the Request, this test no longer makes any sense (i.e. "gql" should throw the same error before anything is sent to the server).

renameVariables(operationOrFragmentDef.selectionSet, aliasName);
return operationOrFragmentDef;
} else {
return definition;
Copy link
Contributor

Choose a reason for hiding this comment

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

This branch isn't covered by any test. Should be tested, or removed if unreachable.

@helfer
Copy link
Contributor

helfer commented Jun 16, 2016

Alright, that all makes sense.

Thanks for making those changes so fast. It looks good to me now, except that a few things aren't covered by tests yet. After adding the couple of tests that are missing, we should be good to go!

@helfer
Copy link
Contributor

helfer commented Jun 16, 2016

🎉

@helfer helfer merged commit 2a36e65 into master Jun 17, 2016
@Poincare Poincare mentioned this pull request Jul 12, 2016
@stubailo stubailo deleted the query_merging branch September 20, 2016 03:43
jbaxleyiii pushed a commit that referenced this pull request Oct 18, 2017
update docs: PropTypes is now a separate package
@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