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

Refactor parameter typing #102

Merged
merged 1 commit into from
Feb 24, 2025
Merged

Refactor parameter typing #102

merged 1 commit into from
Feb 24, 2025

Conversation

calebbourg
Copy link
Collaborator

Description

This PR refactors how we type incoming parameters for certain types of requests.

It adds a QueryFilterMap for type safety around parameters used to filter database queries.
It adds a related IntoQueryFilterMap trait which provides the mechanism for translating types between application layers.

This way we can provide types for endpoint parameters in the web layer and then translate that data into types understood and used by domain and entity_api without these lower layers needing to depend on web (avoiding circular dependency)

This a step toward my current goal of removing web dependency on anything other than domain

Changes

  • Adds QueryFilterMap
  • Adds IntoQueryFilterMap
  • Updates web::error::Error

Testing Strategy

I tested this via Rapidoc and against the FE

Next

  • Apply this pattern to other endpoints
  • Re-Export any necessary entity_api or entity types through domain
  • Remove web dependencies on entity_api and entity
  • Add data validation mechanism to domain
  • Allow for partial updates to data (for user, coaching session, etc. updates)

@calebbourg calebbourg self-assigned this Feb 24, 2025
@calebbourg calebbourg added the design Any kind of software design, visual or otherwise label Feb 24, 2025
@calebbourg calebbourg requested a review from jhodapp February 24, 2025 12:45
@calebbourg calebbourg changed the base branch from main to update_claims February 24, 2025 14:15
Base automatically changed from update_claims to main February 24, 2025 17:14
@jhodapp jhodapp added this to the 1.0-beta1 milestone Feb 24, 2025
Copy link
Member

@jhodapp jhodapp left a comment

Choose a reason for hiding this comment

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

Just one minor thing to adjust, this looks fantastic. Nice evolution of our new domain layer on top of entity_api and encapsulating types that really don't need to be exposed.

}
}
match self {
Error::Domain(ref domain_error) => self.handle_domain_error(domain_error),
Copy link
Member

Choose a reason for hiding this comment

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

This is nice, I didn't know how to use ref like this in such a way as to examine it for pattern matching without consuming/moving it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I didn't know about it either!

@calebbourg calebbourg force-pushed the refactor_parameter_typing branch from 22b0fee to 2df1bd3 Compare February 24, 2025 17:54
@calebbourg calebbourg merged commit bb28178 into main Feb 24, 2025
4 checks passed
@calebbourg calebbourg deleted the refactor_parameter_typing branch February 24, 2025 18:01
@calebbourg calebbourg mentioned this pull request Feb 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design Any kind of software design, visual or otherwise
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

2 participants