Skip to content

Commit

Permalink
Merge pull request #1 from zarathustra323/api-uri
Browse files Browse the repository at this point in the history
Change apiHost to baseApiUri
  • Loading branch information
zarathustra323 authored Oct 16, 2019
2 parents 13d34c3 + 75e4235 commit c18d492
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
bmc.configure({
graphqlUri: 'http://0.0.0.0:11001',
tenantKey: 'acbm_fcp',
apiHost: 'manage.forconstructionpros.com'
baseApiUri: 'https://manage.forconstructionpros.com'
});
</script>
<link rel="stylesheet" href="./dist/latest/bmc.css">
Expand Down
10 changes: 5 additions & 5 deletions src/apollo/create-provider.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import VueApollo from 'vue-apollo';
import createApolloClient from './create-client';

export default ({ graphqlUri, tenantKey, apiHost } = {}) => {
const host = apiHost || window.location.hostname;
if (!graphqlUri || !tenantKey || !host) {
throw new Error('The graphqlUri, tenantKey, and apiHost options are required to create the BaseCMS Apollo Provider.');
export default ({ graphqlUri, tenantKey, baseApiUri } = {}) => {
const apiUri = baseApiUri || window.location.origin;
if (!graphqlUri || !tenantKey || !apiUri) {
throw new Error('The graphqlUri, tenantKey, and baseApiUri options are required to create the BaseCMS Apollo Provider.');
}
const headers = {
'x-tenant-key': tenantKey,
'x-base4-api-hostname': apiHost || window.location.hostname,
'x-base4-api-uri': apiUri,
};
return new VueApollo({
defaultClient: createApolloClient({ uri: graphqlUri, headers }),
Expand Down
4 changes: 2 additions & 2 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ const getApolloProvider = () => {
};

const configure = (options = {}) => {
const { graphqlUri, tenantKey, apiHost } = options;
const { graphqlUri, tenantKey, baseApiUri } = options;
if (hasConfigured()) {
warn('BaseCMS components have already been configured. The following config changes will NOT be applied.', options);
} else {
apolloProvider = createProvider({ graphqlUri, tenantKey, apiHost });
apolloProvider = createProvider({ graphqlUri, tenantKey, baseApiUri });
config = options;
}
};
Expand Down
2 changes: 1 addition & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Vue.config.productionTip = false;
configure({
graphqlUri: 'http://0.0.0.0:11001',
tenantKey: 'acbm_fcp',
apiHost: 'manage.forconstructionpros.com',
baseApiUri: 'https://manage.forconstructionpros.com',
});

new Vue({
Expand Down

0 comments on commit c18d492

Please sign in to comment.