MCPcopy Create free account
hub / github.com/decaporg/decap-cms / getApolloClient

Method getApolloClient

packages/decap-cms-backend-gitlab/src/API.ts:243–277  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

241 }
242
243 getApolloClient() {
244 const authLink = setContext((_, { headers }) => {
245 return {
246 headers: {
247 'Content-Type': 'application/json; charset=utf-8',
248 ...headers,
249 Authorization: this.token ? `Bearer ${this.token}` : '',
250 },
251 };
252 });
253 const httpLink = createHttpLink({
254 uri: this.graphQLAPIRoot,
255 fetch: this.requestFunction
256 ? (input: RequestInfo, init?: RequestInit) => {
257 const url = typeof input === 'string' ? input : input.url;
258 const request = unsentRequest.fromFetchArguments(url, init).toJS() as ApiRequest;
259 return this.requestFunction!(request);
260 }
261 : undefined,
262 });
263 return new ApolloClient({
264 link: authLink.concat(httpLink),
265 cache: new InMemoryCache(),
266 defaultOptions: {
267 watchQuery: {
268 fetchPolicy: NO_CACHE,
269 errorPolicy: 'ignore',
270 },
271 query: {
272 fetchPolicy: NO_CACHE,
273 errorPolicy: 'all',
274 },
275 },
276 });
277 }
278
279 reset() {
280 return this.graphQLClient?.resetStore();

Callers 1

constructorMethod · 0.95

Calls 1

toJSMethod · 0.80

Tested by

no test coverage detected