Revert some of the changes in #2112 (fix #2118)

This commit is contained in:
SachaG 2018-11-04 12:58:16 +09:00
parent 4a2cc23c46
commit fa2fe776de

View file

@ -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 } });
}