summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/lib/graphql.js
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-09-19 01:45:44 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-09-19 01:45:44 +0000
commit85dc423f7090da0a52c73eb66faf22ddb20efff9 (patch)
tree9160f299afd8c80c038f08e1545be119f5e3f1e1 /app/assets/javascripts/lib/graphql.js
parent15c2c8c66dbe422588e5411eee7e68f1fa440bb8 (diff)
downloadgitlab-ce-85dc423f7090da0a52c73eb66faf22ddb20efff9.tar.gz
Add latest changes from gitlab-org/gitlab@13-4-stable-ee
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,