Skip to content

Constrain User api response#878

Merged
ignatiusm merged 8 commits into
devfrom
877-user-api-response
Jul 15, 2026
Merged

Constrain User api response#878
ignatiusm merged 8 commits into
devfrom
877-user-api-response

Conversation

@ignatiusm

Copy link
Copy Markdown
Contributor

The use response contains the whole User model, but not all info should be included.

This PR resolves #877 by:

  • adding tests for the info to be omitted
  • updating types (and api docs)
  • Adding a preview feature for Prisma to enable the omit keyword (more terse than using select)
  • Updating the User endpoints

@plouka13 plouka13 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good! Tested and seems to be working great.

@@ -1,5 +1,7 @@
import { User } from '@prisma/client'

export type UserResponse = Omit<User, 'password' | 'emailHash'>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I wonder if there could be a better name rather than UserResponse. My immediate thought when reading UserResponse was the response object for the API when calling GET /user. Although I understand the intention here now that I read over it. No action required because I don't know a good resolution 😆

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah - naming things is hard. Happy to modify if you think of a better name.

ResetPasswordRequest,
} from 'common/types/api/users'
import { User } from '@prisma/client'
// import { User } from '@prisma/client'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

remove commented line

@ignatiusm

Copy link
Copy Markdown
Contributor Author

Forgot to mention that you may need to run yarn workspace backend prisma generate to regenerate the prisma client with the 'new' Omit feature.

@ignatiusm
ignatiusm merged commit 212d3e8 into dev Jul 15, 2026
6 checks passed
@ignatiusm
ignatiusm deleted the 877-user-api-response branch July 15, 2026 21:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants