Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] No guardian on delete #297

Merged
merged 2 commits into from
Jul 30, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/application-processing/resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ export const completeApplication: Resolver<
},
},
},
// If guardian information given, upsert. Otherwise, delete (SET NULL)
// If guardian information given, upsert.
...(guardian
? {
guardian: {
Expand All @@ -331,7 +331,7 @@ export const completeApplication: Resolver<
},
},
}
: { guardian: { delete: true } }),
: {}),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we still account for the case where there was previously a guardian, but the new application does not contain a guardian? There should still be a delete right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed this case by adding disconnect.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I understand this removes the mapping between the permit and the guardian, but there will be an orphaned guardian in the DB right? Ideally that should be cleaned up too.

},
});

Expand Down
15 changes: 6 additions & 9 deletions tools/hooks/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,12 @@ const useMutation = <
onCompleted: data => {
for (const key in data) {
const result = data[key] as unknown as { ok: boolean; error?: string };
if ('ok' in result && 'error' in result) {
if (!result.ok) {
toast({
status: 'error',
description: result.error,
isClosable: true,
});
}
}
if (result.ok) continue;
toast({
status: 'error',
description: result.error,
isClosable: true,
});
}
options?.onCompleted && options.onCompleted(data);
},
Expand Down
Loading