Add empty console link

This commit is contained in:
Pawel Kowalski 2018-08-20 11:10:45 +02:00
parent d3a65539fb
commit c401bc4d91
1 changed files with 15 additions and 2 deletions

View File

@ -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
})