mirror of
https://github.com/vale981/Vulcan
synced 2025-03-05 17:41:43 -05:00
parent
4a2cc23c46
commit
fa2fe776de
1 changed files with 3 additions and 6 deletions
|
@ -110,17 +110,14 @@ export function getDefaultResolvers(options) {
|
|||
|
||||
// use Dataloader if doc is selected by documentId/_id
|
||||
const documentId = selector.documentId || selector._id;
|
||||
// documentId can be undefined, this is NOT a failure case
|
||||
// for example it allows form to have a "edit" and "new" mode withtout
|
||||
// needing to swap the withSingle hoc
|
||||
if (!documentId) return { result: null };
|
||||
const doc = documentId
|
||||
? await collection.loader.load(documentId)
|
||||
: await Connectors.get(collection, selector);
|
||||
|
||||
const doc = await collection.loader.load(documentId);
|
||||
if (!doc) {
|
||||
if (allowNull) {
|
||||
return { result: null };
|
||||
} else {
|
||||
// if documentId is provided but no document is found, this is usually a failure case
|
||||
const MissingDocumentError = createError('app.missing_document', { message: 'app.missing_document' });
|
||||
throw new MissingDocumentError({ data: { documentId, selector } });
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue