Skip to content

Commit

Permalink
Only fetch schema if client created #173
Browse files Browse the repository at this point in the history
  • Loading branch information
fnoop committed Apr 5, 2020
1 parent 45a12d0 commit e0de3a2
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/plugins/core/CoreApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,31 +162,38 @@ const plugin = {
async createClient (api, clientdata) {
// Add a vuex apis entry
this.$store.commit('core/addApiState', api)
// Fetch and parse the client schema
let schemaFetchPromise = new Promise((resolve, reject) => {
this.fetchClientSchema(api, clientdata).then(() => {
resolve()
})
})
// While the above is resolving, do as much as possible...
// Add an apollo client
let client = null
let schemaFetchPromise = null
if (window.location.protocol == 'https:') {
if (clientdata.httpsEndpoint && clientdata.wssEndpoint && clientdata.schemasEndpoint) {
client = createClient({
httpEndpoint: clientdata.httpsEndpoint,
wsEndpoint: clientdata.wssEndpoint,
websocketsOnly: clientdata.websocketsOnly
})
// Fetch and parse the client schema
schemaFetchPromise = new Promise((resolve, reject) => {
this.fetchClientSchema(api, clientdata).then(() => {
resolve()
})
})
} else {
this.logError(`API client ${this.apis[api].name} does not have SSL endpoints set, and this is an https connection`)
return false
}
} else {
client = createClient({
httpEndpoint: clientdata.httpEndpoint,
wsEndpoint: clientdata.wsEndpoint,
websocketsOnly: clientdata.websocketsOnly
})
// Fetch and parse the client schema
schemaFetchPromise = new Promise((resolve, reject) => {
this.fetchClientSchema(api, clientdata).then(() => {
resolve()
})
})
}
this.$set(this.$apollo.provider.clients, api, client)
// Set the client auth token
Expand Down

0 comments on commit e0de3a2

Please sign in to comment.