Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts/lib/graphql.js')
-rw-r--r--app/assets/javascripts/lib/graphql.js33
1 files changed, 28 insertions, 5 deletions
diff --git a/app/assets/javascripts/lib/graphql.js b/app/assets/javascripts/lib/graphql.js
index 4fed121779e..d2907f401c0 100644
--- a/app/assets/javascripts/lib/graphql.js
+++ b/app/assets/javascripts/lib/graphql.js
@@ -4,6 +4,7 @@ import { createUploadLink } from 'apollo-upload-client';
import { ApolloLink } from 'apollo-link';
import { BatchHttpLink } from 'apollo-link-batch-http';
import csrf from '~/lib/utils/csrf';
+import PerformanceBarService from '~/performance_bar/services/performance_bar_service';
export const fetchPolicies = {
CACHE_FIRST: 'cache-first',
@@ -32,13 +33,35 @@ export default (resolvers = {}, config = {}) => {
credentials: 'same-origin',
};
+ const uploadsLink = ApolloLink.split(
+ operation => operation.getContext().hasUpload || operation.getContext().isSingleRequest,
+ createUploadLink(httpOptions),
+ new BatchHttpLink(httpOptions),
+ );
+
+ const performanceBarLink = new ApolloLink((operation, forward) => {
+ return forward(operation).map(response => {
+ const httpResponse = operation.getContext().response;
+
+ if (PerformanceBarService.interceptor) {
+ PerformanceBarService.interceptor({
+ config: {
+ url: httpResponse.url,
+ },
+ headers: {
+ 'x-request-id': httpResponse.headers.get('x-request-id'),
+ 'x-gitlab-from-cache': httpResponse.headers.get('x-gitlab-from-cache'),
+ },
+ });
+ }
+
+ return response;
+ });
+ });
+
return new ApolloClient({
typeDefs: config.typeDefs,
- link: ApolloLink.split(
- operation => operation.getContext().hasUpload || operation.getContext().isSingleRequest,
- createUploadLink(httpOptions),
- new BatchHttpLink(httpOptions),
- ),
+ link: ApolloLink.from([performanceBarLink, uploadsLink]),
cache: new InMemoryCache({
...config.cacheConfig,
freezeResults: config.assumeImmutableResults,