diff --git a/packages/salesforce/src/schema/compositeSchemaAccess.ts b/packages/salesforce/src/schema/compositeSchemaAccess.ts index d14aa03e..c36af0d9 100644 --- a/packages/salesforce/src/schema/compositeSchemaAccess.ts +++ b/packages/salesforce/src/schema/compositeSchemaAccess.ts @@ -31,36 +31,32 @@ export class CompositeSchemaAccess { public async describe(type: string, field: string): Promise; public async describe(type: string, field?: string): Promise { if (!this.schemaStore.get(type)?.describe) { - await this.enqueue(type); + await this.enqueueDescribe(type); } return this.schemaStore.get(type, field)?.describe; } public async getEntityDefinition(type: string): Promise{ if (!this.schemaStore.get(type)?.tooling) { - await this.enqueue(type); + await this.enqueueTooling(type); } return this.schemaStore.get(type)?.tooling; } public async getFieldDefinition(type: string, field: string): Promise{ if (!this.schemaStore.get(type)?.tooling) { - await this.enqueue(type); + await this.enqueueTooling(type); } return this.schemaStore.get(type, field)?.tooling; } @cache({ unwrapPromise: true, cacheExceptions: true }) - private async enqueue(sobjectType: string) { - const [ describe, entity ] = await Promise.allSettled([ - this.describeAccess.describe(sobjectType), - this.toolingAccess.getEntityDefinition(sobjectType) - ]); + private async enqueueTooling(sobjectType: string) { + await this.toolingAccess.getEntityDefinition(sobjectType); + } - if (describe.status === 'rejected' && entity.status === 'fulfilled') { - throw new Error(`SObject ${sobjectType} is not accessible by the current user`); - } else if (describe.status === 'rejected') { - throw describe.reason; - } + @cache({ unwrapPromise: true, cacheExceptions: true }) + private async enqueueDescribe(sobjectType: string) { + await this.describeAccess.describe(sobjectType); } } \ No newline at end of file