-
-
Notifications
You must be signed in to change notification settings - Fork 922
Disable eager loading partial fetch by default #1069 #1100
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
Conversation
I think we should just use an attribute, since this is a "hint" for the eager loading extension. We do not want to be adding metadata fields that are not well thought out. |
hmm yeah you're right, I'm changing this thanks! To me this is not a bug though, more a feature. |
44ae45c
to
e2aadf6
Compare
Looks good to me! 👍 |
Wow about the tests, as @meyerbaptiste said master is broken. At about 14h gmt + 1 it was okay 😛 |
Partial loading is dangerous because it breaks entities. It must definitely be opt-in. Having partial loading on by default is thus a bug. |
I don't believe that this needs to be configurable, not in this way. We should instead make sure that partial loading is only activated on an opt-in basis. |
6ae4991
to
752455d
Compare
{ | ||
$this->propertyNameCollectionFactory = $propertyNameCollectionFactory; | ||
$this->propertyMetadataFactory = $propertyMetadataFactory; | ||
$this->resourceMetadataFactory = $resourceMetadataFactory; | ||
$this->maxJoins = $maxJoins; | ||
$this->forceEager = $forceEager; | ||
$this->fetchPartial = $fetchPartial; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name is fine @teohhanhui 😛 ?
be428cc
to
3f2d865
Compare
@@ -50,6 +50,7 @@ public function getConfigTreeBuilder() | |||
->addDefaultsIfNotSet() | |||
->children() | |||
->booleanNode('enabled')->defaultTrue()->info('To enable or disable eager loading')->end() | |||
->booleanNode('fetch_partial')->defaultFalse()->info('Fetch only partial data according to serialization groups')->end() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should add:
"If enabled, Doctrine ORM entities will NOT work as expected if any of the other fields are used."
😝
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
298cd49
to
cf4831b
Compare
ping @api-platform/core-team this one should be good to go. Should we merge this on |
This is a bugfix so it should go into |
@@ -44,13 +44,14 @@ | |||
private $serializerContextBuilder; | |||
private $requestStack; | |||
|
|||
public function __construct(PropertyNameCollectionFactoryInterface $propertyNameCollectionFactory, PropertyMetadataFactoryInterface $propertyMetadataFactory, ResourceMetadataFactoryInterface $resourceMetadataFactory, int $maxJoins = 30, bool $forceEager = true, RequestStack $requestStack = null, SerializerContextBuilderInterface $serializerContextBuilder = null) | |||
public function __construct(PropertyNameCollectionFactoryInterface $propertyNameCollectionFactory, PropertyMetadataFactoryInterface $propertyMetadataFactory, ResourceMetadataFactoryInterface $resourceMetadataFactory, int $maxJoins = 30, bool $forceEager = true, bool $fetchPartial = false, RequestStack $requestStack = null, SerializerContextBuilderInterface $serializerContextBuilder = null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this a BC break?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops... Another ugly hack required?
p/s: When can we actually break things again? In the Symfony model (deprecations only), the answer seems to be "never, unless you create new interfaces / classes". \o/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kinda yes. I'll try to handle backward compatibility! I thought about setting this new argument as last one, do you think it'd be a solution?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@teohhanhui I can also put this as last argument. Then, no ugly hacks nor BC break no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, sure. But then there's still the underlying problem of piling on layers upon layers of bad design (because we don't really have a choice).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah sure, when we can break again we will refactor those don't worry :).
b35c20b
to
ce14652
Compare
LGTM, can someone do a last review? Thanks! |
Disable eager loading partial fetch by default api-platform#1069
As discussed in #1069 sometimes you still want to fetch a property, even though it will not be serialized. This new metadata attribute adds a flag that will prevent the eager loader to check the
readable
state.ping @bwegrzyn