11//#region > Imports
2- //#PACKAGE "apollo-client"
3- //## npm install "apollo-client"@2.6.8
4- // Contains the client for graphql handling
5- import { ApolloClient } from "apollo-client" ;
6- //#PACKAGE "apollo-link-http"
7- //## npm install "apollo-link-http"@1.5.16
8- // Contains the link for the apollo client
9- import { HttpLink } from "apollo-link-http" ;
10- //#PACKAGE "apollo-cache-inmemory"
11- //## npm install "apollo-cache-inmemory"@1.6.5
12- // Contains cache handling for apollo
2+ //#PACKAGE "@apollo/client"
133import {
4+ ApolloClient ,
5+ ApolloLink ,
146 InMemoryCache ,
15- IntrospectionFragmentMatcher ,
167 NormalizedCacheObject ,
17- } from "apollo-cache-inmemory" ;
8+ HttpLink ,
9+ } from "@apollo/client" ;
10+ //#PACKAGE "'apollo-upload-client"
11+ // Contains the link for the apollo client
12+ import { createUploadLink } from "apollo-upload-client" ;
1813//#PACKAGE "graphql"
1914//## npm install "graphql"@14.6.0
2015// Contains the interface for gql queries, mutations and subscriptions
@@ -32,7 +27,7 @@ import { ApolloResult } from "./index";
3227/** @class Apollo client for graphql handling */
3328class Apollo implements ApolloEndpoint {
3429 //> Fields
35- private link : HttpLink ;
30+ private link : ApolloLink ;
3631 private cache : InMemoryCache ;
3732 private client : ApolloClient < NormalizedCacheObject > ;
3833
@@ -49,26 +44,18 @@ class Apollo implements ApolloEndpoint {
4944 */
5045 constructor ( uri : string , options : Options ) {
5146 this . headers = options . headers ;
52- const fragmentMatcher = new IntrospectionFragmentMatcher ( {
53- introspectionQueryResultData : {
54- __schema : {
55- types : [ ] ,
56- } ,
57- } ,
58- } ) ;
5947
6048 try {
61- this . cache = new InMemoryCache ( { fragmentMatcher } ) ;
49+ this . cache = new InMemoryCache ( ) ;
6250 } catch {
6351 //#ERROR
6452 throw new Error ( "An error occurred while initializing the cache!" ) ;
6553 }
6654
6755 try {
68- this . link = new HttpLink ( {
69- uri,
70- headers : options . headers ,
71- } ) ;
56+ const uploadLink = createUploadLink ( { uri, headers : options . headers } ) ;
57+
58+ this . link = ApolloLink . from ( [ uploadLink ] ) ;
7259 } catch {
7360 //#ERROR
7461 throw new Error ( "An error occurred while initializing the API link!" ) ;
0 commit comments