From c401bc4d914fd22d14c115959c72098dac2f2bb5 Mon Sep 17 00:00:00 2001 From: Pawel Kowalski Date: Mon, 20 Aug 2018 11:10:45 +0200 Subject: [PATCH] Add empty console link --- client/src/graphql/client.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/client/src/graphql/client.js b/client/src/graphql/client.js index 6951bd1f..aa607e1a 100644 --- a/client/src/graphql/client.js +++ b/client/src/graphql/client.js @@ -1,6 +1,7 @@ import {InMemoryCache} from 'apollo-cache-inmemory/lib/index' import {HttpLink} from 'apollo-link-http/lib/index' import {ApolloClient} from 'apollo-client/index' +import {ApolloLink} from 'apollo-link' import fetch from 'unfetch' const httpLink = new HttpLink({ @@ -12,10 +13,22 @@ const httpLink = new HttpLink({ } }) +const consoleLink = new ApolloLink((operation, forward) => { + console.log(`starting request for ${operation.operationName}`); + + return forward(operation).map((data) => { + console.log(`ending request for ${operation.operationName}`); + + return data + }) +}) + +const composedLink = ApolloLink.from([consoleLink, httpLink]); + // Create the apollo client export default new ApolloClient({ - // link: composedLink, - link: httpLink, + link: composedLink, + // link: httpLink, cache: new InMemoryCache(), connectToDevTools: true })