Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async _doUpdate(forceRefresh, hints) {
log.debug('begin update, forceRefresh=%s', forceRefresh);
let priorCache = this._schemaCache;
let running = new RunningIndexers(
await this._seedSchema(),
this.client,
this.emit.bind(this),
this.schemaLoader.ownTypes(),
getOwner(this)
);
try {
let newSchema = await running.update(forceRefresh, hints);
if (this._schemaCache === priorCache) {
// nobody else has done a more recent update of the schema
// cache than us, so we can try to update it.
if (priorCache) {
let oldSchema = await priorCache;
if (!newSchema.equalTo(oldSchema)) {
log.info('schema was changed');
this._schemaCache = newSchema;
if (oldSchema) {
await oldSchema.teardown();
}
}
} else {
_instance(resolverName) {
if (resolverName) {
return getOwner(this).lookup(resolverName);
}
}
_factory(resolverName) {
if (resolverName) {
return getOwner(this).factoryFor(resolverName);
}
}
this._schemaCache = (async () => {
let running = new RunningIndexers(
await this._seedSchema(),
this.client,
this.emit.bind(this),
this.schemaLoader.ownTypes(),
getOwner(this)
);
try {
return await running.schemas();
} finally {
await running.destroy();
}
})();
}
log.trace('default data source %j', defaultDataSource);
let groups = findGroups(models, fields, computedFields);
let types = findTypes(
models,
fields,
computedFields,
constraints,
dataSources,
defaultDataSource,
grants,
groups
);
validateRelatedTypes(types, fields);
log.debug(`SchemaLoader.loadFrom completed loading schema`);
return getOwner(this)
.factoryFor('hub:schema')
.create({ types, fields, computedFields, dataSources, inputModels, plugins, grants });
}
}