Skip to content

Commit

Permalink
More cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
emmatown committed Jun 3, 2021
1 parent 28aa5ea commit 1a38262
Showing 1 changed file with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ async function handleCreateAndUpdate(
foreignList: InitialisedList,
target: string
) {
if (value.connect && value.create) {
throw new Error(`Nested mutation operation invalid for ${target}`);
}
if (value.connect) {
try {
await context.db.lists[foreignList.listKey].findOne({ where: value.connect as any });
Expand Down Expand Up @@ -221,10 +224,6 @@ export function resolveRelateToOneForCreateInput(
if (value == null) {
return undefined;
}
const numOfKeys = Object.keys(value).length;
if (numOfKeys !== 1) {
throw new Error(`Nested mutation operation invalid for ${target}`);
}
return handleCreateAndUpdate(value, nestedMutationState, context, foreignList, target);
};
}
Expand All @@ -243,9 +242,6 @@ export function resolveRelateToOneForUpdateInput(
if (value == null) {
return undefined;
}
if (value.connect && value.create) {
throw new Error(`Nested mutation operation invalid for ${target}`);
}
if (value.connect || value.create) {
return handleCreateAndUpdate(value, nestedMutationState, context, foreignList, target);
}
Expand Down

0 comments on commit 1a38262

Please sign in to comment.