From 363bd4dbc1a75360a6e57c03fcaefbade04da0b0 Mon Sep 17 00:00:00 2001 From: amandajliu Date: Mon, 18 Jul 2016 15:53:18 -0700 Subject: [PATCH] Fixed indentation and removed extra code --- CHANGELOG.md | 3 ++- src/queries/queryTransform.ts | 10 +++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0457bc3a69a..0b7a089b0e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/queries/queryTransform.ts b/src/queries/queryTransform.ts index 4c40d5570a0..d0b5074931a 100644 --- a/src/queries/queryTransform.ts +++ b/src/queries/queryTransform.ts @@ -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); @@ -60,7 +60,7 @@ 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 @@ -68,8 +68,8 @@ function traverseSelectionSet(selectionSet: SelectionSet, queryTransformers: Que 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; }