From 3684f5c9d560bf920c451bbb346703207b2db50c Mon Sep 17 00:00:00 2001 From: clarencenpy Date: Thu, 9 Aug 2018 12:43:57 -0700 Subject: [PATCH] Add support for deferred queries --- packages/graphql-playground-react/package.json | 3 ++- .../src/state/sessions/fetchingSagas.ts | 13 ++++++++----- packages/graphql-playground-react/yarn.lock | 12 +++++++++--- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/packages/graphql-playground-react/package.json b/packages/graphql-playground-react/package.json index cd2728396..76b9ba228 100644 --- a/packages/graphql-playground-react/package.json +++ b/packages/graphql-playground-react/package.json @@ -119,7 +119,8 @@ }, "dependencies": { "apollo-link": "^1.0.7", - "apollo-link-http": "^1.3.2", + "apollo-link-http": "alpha", + "apollo-link-patch": "alpha", "apollo-link-ws": "1.0.8", "calculate-size": "^1.1.1", "classnames": "^2.2.5", diff --git a/packages/graphql-playground-react/src/state/sessions/fetchingSagas.ts b/packages/graphql-playground-react/src/state/sessions/fetchingSagas.ts index 212bf0029..ebc3f1b18 100644 --- a/packages/graphql-playground-react/src/state/sessions/fetchingSagas.ts +++ b/packages/graphql-playground-react/src/state/sessions/fetchingSagas.ts @@ -2,6 +2,7 @@ import { ApolloLink, execute } from 'apollo-link' import { parseHeaders } from '../../components/Playground/util/parseHeaders' import { SubscriptionClient } from 'subscriptions-transport-ws' import { HttpLink } from 'apollo-link-http' +import { DeferPatchLink } from 'apollo-link-patch' import { WebSocketLink } from 'apollo-link-ws' import { isSubscription } from '../../components/Playground/util/hasSubscription' import { @@ -67,11 +68,13 @@ export const defaultLinkCreator = ( connectionParams = { ...headers } } - const httpLink = new HttpLink({ - uri: session.endpoint, - headers, - credentials, - }) + const httpLink = new DeferPatchLink().concat( + new HttpLink({ + uri: session.endpoint, + headers, + credentials, + }), + ) if (!(wsEndpoint || subscriptionEndpoint)) { return { link: httpLink } diff --git a/packages/graphql-playground-react/yarn.lock b/packages/graphql-playground-react/yarn.lock index c4144d4da..e82e657bf 100644 --- a/packages/graphql-playground-react/yarn.lock +++ b/packages/graphql-playground-react/yarn.lock @@ -224,13 +224,19 @@ apollo-link-http-common@^0.2.4: dependencies: apollo-link "^1.2.2" -apollo-link-http@^1.3.2: - version "1.5.4" - resolved "https://registry.yarnpkg.com/apollo-link-http/-/apollo-link-http-1.5.4.tgz#b80b7b4b342c655b6a5614624b076a36be368f43" +apollo-link-http@alpha: + version "1.6.0-alpha.5" + resolved "https://registry.yarnpkg.com/apollo-link-http/-/apollo-link-http-1.6.0-alpha.5.tgz#1b50e34304a2f29a669a754fac0fcdec14f23ca7" dependencies: apollo-link "^1.2.2" apollo-link-http-common "^0.2.4" +apollo-link-patch@alpha: + version "0.1.0-alpha.1" + resolved "https://registry.yarnpkg.com/apollo-link-patch/-/apollo-link-patch-0.1.0-alpha.1.tgz#57084c31efc462c53f1009a81128654da7dedd45" + dependencies: + apollo-link "^1.2.2" + apollo-link-ws@1.0.8: version "1.0.8" resolved "https://registry.yarnpkg.com/apollo-link-ws/-/apollo-link-ws-1.0.8.tgz#ac1de8f29e92418728479a9a523af9f75b9ccc8b"