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

Enhancement: multiple DTO configurations and dynamic dto backend selection #2799

Open
crisog opened this issue Nov 29, 2023 · 1 comment
Open
Labels
DTOs This is related to our DTO feature Enhancement This is a new feature or request

Comments

@crisog
Copy link
Sponsor Contributor

crisog commented Nov 29, 2023

Summary

I propose a feature for dynamic/contextual DTO configurations. This feature aims to address the following challenge: selectively exposing different data fields based on certain conditions (e.g., owners of a resource seeing private data, while other users see a restricted view of the same resource).

Basic Example

Context: A social media platform where users have both public and private information on their profiles.

Functionality: When a user views their own profile, they see all their information, including private data like email address and phone number. However, when another user views someone else's profile, the private information is omitted.

Drawbacks and Impact

Dynamically determining which DTO configuration to use for each request might introduce a slight overhead, especially if the decision logic is complex. But it's optional, and up to the user to use it.

Generating accurate OpenAPI documentation that reflects different data views based on this multi-configuration scenario can be challenging.

Unresolved questions

A less complex solution would be allowing a callback for the exclude and include fields instead of the entire DTO, but seems like a band-aid solution. Throwing it here anyway.


Note

While we are open for sponsoring on GitHub Sponsors and
OpenCollective, we also utilize Polar.sh to engage in pledge-based sponsorship.

Check out all issues funded or available for funding on our Polar.sh Litestar dashboard

  • If you would like to see an issue prioritized, make a pledge towards it!
  • We receive the pledge once the issue is completed & verified
  • This, along with engagement in the community, helps us know which features are a priority to our users.
Fund with Polar
@crisog crisog added the Enhancement This is a new feature or request label Nov 29, 2023
@peterschutt
Copy link
Contributor

@peterschutt peterschutt changed the title Enhancement: Dynamic DTO Configuration Enhancement: multiple DTO configurations and dynamic dto backend selection Dec 1, 2023
@JacobCoffee JacobCoffee added the DTOs This is related to our DTO feature label Dec 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DTOs This is related to our DTO feature Enhancement This is a new feature or request
Projects
Status: Ideas
Development

No branches or pull requests

3 participants