Commit 64d13d5a authored by Phil Hughes's avatar Phil Hughes

Merge branch 'kp-add-graphql-full-config-support' into 'master'

Add support for second `config` param in GraphQL wrapper lib

See merge request gitlab-org/gitlab-ce!28705
parents 43b3d304 6a57552a
...@@ -3,12 +3,12 @@ import { InMemoryCache } from 'apollo-cache-inmemory'; ...@@ -3,12 +3,12 @@ import { InMemoryCache } from 'apollo-cache-inmemory';
import { createUploadLink } from 'apollo-upload-client'; import { createUploadLink } from 'apollo-upload-client';
import csrf from '~/lib/utils/csrf'; import csrf from '~/lib/utils/csrf';
export default (resolvers = {}, baseUrl = '') => { export default (resolvers = {}, config = {}) => {
let uri = `${gon.relative_url_root}/api/graphql`; let uri = `${gon.relative_url_root}/api/graphql`;
if (baseUrl) { if (config.baseUrl) {
// Prepend baseUrl and ensure that `///` are replaced with `/` // Prepend baseUrl and ensure that `///` are replaced with `/`
uri = `${baseUrl}${uri}`.replace(/\/{3,}/g, '/'); uri = `${config.baseUrl}${uri}`.replace(/\/{3,}/g, '/');
} }
return new ApolloClient({ return new ApolloClient({
...@@ -18,7 +18,7 @@ export default (resolvers = {}, baseUrl = '') => { ...@@ -18,7 +18,7 @@ export default (resolvers = {}, baseUrl = '') => {
[csrf.headerKey]: csrf.token, [csrf.headerKey]: csrf.token,
}, },
}), }),
cache: new InMemoryCache(), cache: new InMemoryCache(config.cacheConfig),
resolvers, resolvers,
}); });
}; };
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment