❔ Social media profiles hidden information?
in social media websites
when i set something like my email to private or only shown for me
does the api return a different DTO each time?
and in that case, I will need to have 99999 DTOs depending on how many properties I have and how many combinations of information that can be hidden/shown?
9 Replies
@shadilios Then take a look at GraphQL. You can write your query from the client and retrieve the exact amount of data you need.
If you choose to go with GraphQL. Take a look at hotchocolate -> https://chillicream.com/docs/hotchocolate
Introduction - Hot Chocolate
We're building the ultimate GraphQL platform
since you arent giving any more concrete examples, i wont go to deep into the topic, but an api can have optional fields, meaning they dont have to be part of the payload, your dto then just sets the value to null or whatever you want to do with it. one dto is normally more than enough for such a case
How I do it is remove certain fields from the DTO
So like email address will be null client side
But the model is the same
pretty much jea
Email address field in profile model
Ye
You could setup a pattern for your dto validation like:
Your parameter for the Func would be an IDictionary, or you might be able to use, as, to try casting it to your dto
Make a special attribute for model validation, and voila
Just use
null
, and you can tell ASP to remove null fields from the responseWas this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.