-
-
Notifications
You must be signed in to change notification settings - Fork 213
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
Include/exclude does not work on the Resource
class
#868
Comments
Ressource
class Resource
class
I think adding |
I really don't think so because the trait to allow include and exclude Is used on it as well as the IncludeableData contract, if that was the case, the trait and interface should not be on it, and the doc suggests using it as an alternative to Data that doesn't have data validation (and not exclude include) and thus performs a bit better
https://spatie.be/docs/laravel-data/v4/as-a-resource/from-data-to-resource I don't see how wanting to use the lazy property feature of the library on a resource is opinionated I think you are mixing up Resource and Dto, yes Dto is the generic one with none of the features on it but Resource is not On the page that you mention I also see that
It's not really mentionned that IncludeableData will not work without ContextableData, I think IncludeableData should extend the ContextableData in the next major because it doesn't work without it, same for the trait https://github.com/spatie/laravel-data/blob/main/src/Concerns/IncludeableData.php#L13 |
hmm yes I see your point now. I was mixing up Resource and Dto. |
I've added it to Resource, IncludeableData earlier extended ContextableData but that gave circular dependency problems when trying to analyze data for TypeScript Transformer 3. This should fix the issue. |
✏️ Describe the bug
Using
include('someProp')
orexclude
on a DataClass that extends theResource
class does not work becauseResource
is missing theContextableDataContract
but has the traitThis means that this condition
laravel-data/src/Concerns/TransformableData.php
Lines 35 to 37 in cf86d7a
Cannot pass and the transformationContext does not contain any partials
Here is a pest case that demonstrates the issue
The text was updated successfully, but these errors were encountered: