11import { ApolloClient , FetchPolicy } from 'apollo-client' ;
22import { InMemoryCache } from 'apollo-cache-inmemory' ;
33import { HttpLink } from 'apollo-link-http' ;
4+ import { ApolloLink } from 'apollo-link' ;
45import Context from '../common/context' ;
56import { Arguments , Data } from '../support/interfaces' ;
67import Transformer from './transformer' ;
@@ -15,7 +16,7 @@ export default class Apollo {
1516 * The http link instance to use.
1617 * @type {HttpLink }
1718 */
18- private readonly httpLink : HttpLink ;
19+ private readonly httpLink : ApolloLink ;
1920
2021 /**
2122 * The ApolloClient instance
@@ -29,12 +30,17 @@ export default class Apollo {
2930 public constructor ( ) {
3031 const context = Context . getInstance ( ) ;
3132
32- this . httpLink = new HttpLink ( {
33- uri : context . options . url ? context . options . url : '/graphql' ,
34- credentials : context . options . credentials ? context . options . credentials : 'same-origin' ,
35- headers : context . options . headers ? context . options . headers : { } ,
36- useGETForQueries : Boolean ( context . options . useGETForQueries )
37- } ) ;
33+ // This allows the test suite to pass a custom link
34+ if ( context . options . link ) {
35+ this . httpLink = context . options . link ;
36+ } else {
37+ this . httpLink = new HttpLink ( {
38+ uri : context . options . url ? context . options . url : '/graphql' ,
39+ credentials : context . options . credentials ? context . options . credentials : 'same-origin' ,
40+ headers : context . options . headers ? context . options . headers : { } ,
41+ useGETForQueries : Boolean ( context . options . useGETForQueries )
42+ } ) ;
43+ }
3844
3945 this . apolloClient = new ApolloClient ( {
4046 link : this . httpLink ,
0 commit comments