Disable eager loading partial fetch by default #1069#1100
Disable eager loading partial fetch by default #1069#1100soyuka merged 1 commit intoapi-platform:2.0from
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->resourceMetadataFactory = $resourceMetadataFactory; | ||
| $this->maxJoins = $maxJoins; | ||
| $this->forceEager = $forceEager; | ||
| $this->fetchPartial = $fetchPartial; |
be428cc to
3f2d865
Compare
| ->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.
I think we should add:
"If enabled, Doctrine ORM entities will NOT work as expected if any of the other fields are used."
😝
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 |
| 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.
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.
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.
@teohhanhui I can also put this as last argument. Then, no ugly hacks nor BC break no?
There was a problem hiding this comment.
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.
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
readablestate.ping @bwegrzyn