Refactoring, extract uni-info-watcher GQL client (#226)

* Refactor common code in uni-watcher and uni-info-watcher.

* Implement client.ts in uni-info-watcher for queries and use in smoke-test.

* Disable cache in graphql client.

Co-authored-by: nabarun <nabarun@deepstacksoft.com>
This commit is contained in:
Ashwin Phatak
2021-08-24 11:55:29 +05:30
committed by GitHub
co-authored by nabarun
parent 885a55e513
commit 3ff2fdf11b
31 changed files with 1126 additions and 888 deletions
+22 -2
View File
@@ -8,7 +8,17 @@ import fetch from 'cross-fetch';
import { SubscriptionClient } from 'subscriptions-transport-ws';
import ws from 'ws';
import { ApolloClient, NormalizedCacheObject, split, HttpLink, InMemoryCache, DocumentNode, TypedDocumentNode, from } from '@apollo/client/core';
import {
ApolloClient,
NormalizedCacheObject,
split,
HttpLink,
InMemoryCache,
DocumentNode,
TypedDocumentNode,
from,
DefaultOptions
} from '@apollo/client/core';
import { getMainDefinition } from '@apollo/client/utilities';
import { WebSocketLink } from '@apollo/client/link/ws';
@@ -71,9 +81,19 @@ export class GraphQLClient {
link = splitLink;
}
const defaultOptions: DefaultOptions = {
watchQuery: {
fetchPolicy: 'no-cache'
},
query: {
fetchPolicy: 'no-cache'
}
};
this._client = new ApolloClient({
link,
cache: new InMemoryCache()
cache: new InMemoryCache(),
defaultOptions
});
}