drupal-graphql / graphql

GraphQL integration for Drupal 9/10
288 stars 201 forks source link

[4.x] Remove caching clause in FromParent resolver #1274

Open Kingdutch opened 2 years ago

Kingdutch commented 2 years ago

I think we can remove the explicit adding of the value to our cacheability information in https://github.com/drupal-graphql/graphql/blob/fa9764fb93284481cc4f3de1124e0a1f4c987176/src/GraphQL/Resolver/ParentValue.php#L19-L21

Since we already do so for all the results in our field resolver https://github.com/drupal-graphql/graphql/blob/fa9764fb93284481cc4f3de1124e0a1f4c987176/src/Entity/Server.php#L354-L358

This may seem like a small optimisation, but when looking at a relatively complex query addCacheableDependency was actually a place where the most time was spent and I theFromParent producer is actually on a hot path because a lot of fields use the parent's value to refine it further, so removing this unneeded function call may make a difference.

Kingdutch commented 2 years ago

If my understanding is correct the same would go for https://github.com/drupal-graphql/graphql/blob/fa9764fb93284481cc4f3de1124e0a1f4c987176/src/GraphQL/Resolver/Value.php#L35-L37