From 04ae844a1a23d1a82cf4305611c6d1ba53b31b79 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Tue, 5 Dec 2017 19:25:32 +0100 Subject: [PATCH] Use graphql-ast-tools --- client/coral-framework/services/graphql.js | 6 +++--- package.json | 1 + yarn.lock | 6 ++++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/client/coral-framework/services/graphql.js b/client/coral-framework/services/graphql.js index 859d57d8a..fb40ecf71 100644 --- a/client/coral-framework/services/graphql.js +++ b/client/coral-framework/services/graphql.js @@ -1,4 +1,4 @@ -import reduceDocument, {createTypeGetter} from '../graphql/reduceDocument'; +import {transformDocument, createTypeGetter} from 'graphql-ast-tools'; import {addTypenameToDocument} from 'apollo-client/queries/queryTransform'; /** @@ -10,7 +10,7 @@ export function createGraphQLService(registry, { introspectionData, optimize = false, }) { - const reduceOptions = { + const transformOptions = { typeGetter: optimize && introspectionData ? createTypeGetter(introspectionData) : null, // Use shared fragment map. @@ -27,7 +27,7 @@ export function createGraphQLService(registry, { document = registry.resolveFragments(document); if (optimize) { - document = reduceDocument(document, reduceOptions); + document = transformDocument(document, transformOptions); } // We also add typenames to the document which apollo would usually do, diff --git a/package.json b/package.json index 5ac69b6e6..7876c8636 100644 --- a/package.json +++ b/package.json @@ -107,6 +107,7 @@ "fs-extra": "^4.0.1", "gql-merge": "^0.0.4", "graphql": "^0.9.1", + "graphql-ast-tools": "^0.1.5", "graphql-docs": "0.2.0", "graphql-errors": "^2.1.0", "graphql-redis-subscriptions": "1.3.0", diff --git a/yarn.lock b/yarn.lock index 78ded3707..a536670b9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3519,6 +3519,12 @@ graphql-anywhere@^3.0.1: version "3.1.0" resolved "https://registry.yarnpkg.com/graphql-anywhere/-/graphql-anywhere-3.1.0.tgz#3ea0d8e8646b5cee68035016a9a7557c15c21e96" +graphql-ast-tools@^0.1.5: + version "0.1.5" + resolved "https://registry.yarnpkg.com/graphql-ast-tools/-/graphql-ast-tools-0.1.5.tgz#840c8027b71d60b560482d08e70988e5bc91da90" + dependencies: + apollo-utilities "^1.0.3" + graphql-docs@0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/graphql-docs/-/graphql-docs-0.2.0.tgz#cf803f9c9d354fa03e89073d74e419261a5bfa74"