Skip to content

Commit

Permalink
Fixed indentation and removed extra code
Browse files Browse the repository at this point in the history
  • Loading branch information
amandajliu authored and Sashko Stubailo committed Jul 18, 2016
1 parent c741d9b commit 363bd4d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
Expect active development and potentially significant breaking changes in the `0.x` track. We'll try to be diligent about releasing a `1.0` version in a timely fashion (ideally within 3 to 6 months), to signal the start of a more stable API.

### vNEXT
- Include fragments in query transformers, and new methods that allow transforming query document with multiple query transformers. [Issue #373](https://github.com/apollostack/apollo-client/issues/373) [PR #412](https://github.com/apollostack/apollo-client/pull/412)

- Make sure query transformers are also applied to named fragments, and new methods that allow transforming query document with multiple query transformers. [Issue #373](https://github.com/apollostack/apollo-client/issues/373) [PR #412](https://github.com/apollostack/apollo-client/pull/412)

### v0.4.3

Expand Down
10 changes: 5 additions & 5 deletions src/queries/queryTransform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export function addTypenameToSelectionSet(selectionSet: SelectionSet) {
function traverseSelectionSet(selectionSet: SelectionSet, queryTransformers: QueryTransformer[]) {
if (selectionSet && selectionSet.selections) {
queryTransformers.forEach((transformer) => {
(transformer as QueryTransformer)(selectionSet); // transforms in place
transformer(selectionSet); // transforms in place
selectionSet.selections.forEach((selection) => {
if (selection.kind === 'Field' || selection.kind === 'InlineFragment') {
traverseSelectionSet((selection as Field | InlineFragment).selectionSet, queryTransformers);
Expand All @@ -60,16 +60,16 @@ function traverseSelectionSet(selectionSet: SelectionSet, queryTransformers: Que
}
}
/**
* Applies transformers to document in place.
* Applies transformers to document and returns a new transformed document.
* @param {Document} doc - A GraphQL document that will be transformed
* @param {QueryTranformer[]} queryTransformers - transformers to be applied to the document
* @ return {Document} - a new transformed document
*/
export function applyTransformers(doc: Document, queryTransformers: QueryTransformer[]): Document {
checkDocument(doc);
const docClone = cloneDeep(doc);
docClone.definitions.forEach((definition) => {
traverseSelectionSet((definition as (OperationDefinition | FragmentDefinition)).selectionSet, queryTransformers);
});
docClone.definitions.forEach((definition) => {
traverseSelectionSet((definition as (OperationDefinition | FragmentDefinition)).selectionSet, queryTransformers);
});
return docClone;
}

0 comments on commit 363bd4d

Please sign in to comment.