Closed goo32 closed 7 years ago
I like this suggestion, and it ties in nicely to what I replied on #125. That said, I don't think a boolean is sufficient. As far as I can see, there are three options:
null
or if the property does not exist on the model)null
, otherwise include it)The third is the current behavior, and should remain the default.
What about something like this?...
BelongsTo<AuthorResource>("Author"); // Default behaviour ie. ApiResource.ExcludeIfNull
BelongsTo<AuthorResource>("Author", ApiResource.Include);
BelongsTo<AuthorResource>("Author", ApiResource.Exclude);
Yes, I like the idea of an enum, probably named something like SideLoad
or Include
. Possible values should be:
IfProvided
(default)Always
Never
Forgive me if I'm misunderstanding, but maybe this is best left to be decided by the actual web request using the include
request parameter?
From my understanding Saule currently includes relationships by default. A nice enhancement would be to allow an optional include parameter on the association that would be respected on serialization.
eg.
In resource model...
`BelongsTo("Author"); // Default include = true``
Would be serialized to...
While...
`BelongsTo("Author", false);``