tnc-ca-geo / animl-api

Backend for https://animl.camera
4 stars 0 forks source link

TypeScript: Resolvers(mutations.createUser): Ensure StandardPayload is returned #201

Closed alukach closed 3 weeks ago

alukach commented 3 weeks ago

In mutations.createUser, we are expected to return a StandardPayload:

https://github.com/tnc-ca-geo/animl-api/blob/27b3e3d955208ffdaa061aeced28689e76644ad4/src/api/type-defs/root/Mutation.ts#L10

https://github.com/tnc-ca-geo/animl-api/blob/27b3e3d955208ffdaa061aeced28689e76644ad4/src/api/type-defs/payloads/StandardPayload.ts#L1-L5

However, it's possible that the handler returns undefined if no exception is thrown: https://github.com/tnc-ca-geo/animl-api/blob/a2483e87a4ddaa1aab673aec3aa2df7991980f25/src/api/db/models/User.js#L43-L89

This PR resolves that, ensuring that a StandardPayload is always returned (unless an uncaught error is raised).