Skip to content

Commit 0806105

Browse files
committed
B2B-2658: Implement GraphQL Resolver Cache for Customer query
- added hydration skip procedure
1 parent 14db6c0 commit 0806105

File tree

11 files changed

+37
-39
lines changed

11 files changed

+37
-39
lines changed

app/code/Magento/CustomerGraphQl/Model/Resolver/CacheKey/FactorProvider/CurrentCustomerId.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
namespace Magento\CustomerGraphQl\Model\Resolver\CacheKey\FactorProvider;
99

1010
use Magento\GraphQl\Model\Query\ContextInterface;
11-
use Magento\GraphQlResolverCache\Model\Resolver\Result\CacheKey\GenericFactorInterface;
11+
use Magento\GraphQlResolverCache\Model\Resolver\Result\CacheKey\GenericFactorProviderInterface;
1212

1313
/**
1414
* Provides logged-in customer id as a factor to use in the cache key for resolver cache.
1515
*/
16-
class CurrentCustomerId implements GenericFactorInterface
16+
class CurrentCustomerId implements GenericFactorProviderInterface
1717
{
1818
/**
1919
* Factor name.

app/code/Magento/CustomerGraphQl/Model/Resolver/CacheKey/FactorProvider/CustomerGroup.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99

1010
use Magento\Customer\Api\Data\GroupInterface;
1111
use Magento\GraphQl\Model\Query\ContextInterface;
12-
use Magento\GraphQlResolverCache\Model\Resolver\Result\CacheKey\GenericFactorInterface;
12+
use Magento\GraphQlResolverCache\Model\Resolver\Result\CacheKey\GenericFactorProviderInterface;
1313

1414
/**
1515
* Provides customer group as a factor to use in the cache key for resolver cache.
1616
*/
17-
class CustomerGroup implements GenericFactorInterface
17+
class CustomerGroup implements GenericFactorProviderInterface
1818
{
1919
private const NAME = "CUSTOMER_GROUP";
2020

app/code/Magento/CustomerGraphQl/Model/Resolver/CacheKey/FactorProvider/CustomerTaxRate.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
use Magento\Customer\Api\Data\GroupInterface;
1111
use Magento\Customer\Model\ResourceModel\GroupRepository as CustomerGroupRepository;
1212
use Magento\GraphQl\Model\Query\ContextInterface;
13-
use Magento\GraphQlResolverCache\Model\Resolver\Result\CacheKey\GenericFactorInterface;
13+
use Magento\GraphQlResolverCache\Model\Resolver\Result\CacheKey\GenericFactorProviderInterface;
1414
use Magento\Tax\Model\Calculation as CalculationModel;
1515
use Magento\Tax\Model\ResourceModel\Calculation as CalculationResource;
1616

1717
/**
1818
* Provides tax rate as a factor to use in the cache key for resolver cache.
1919
*/
20-
class CustomerTaxRate implements GenericFactorInterface
20+
class CustomerTaxRate implements GenericFactorProviderInterface
2121
{
2222
private const NAME = 'CUSTOMER_TAX_RATE';
2323

app/code/Magento/CustomerGraphQl/Model/Resolver/CacheKey/FactorProvider/IsLoggedIn.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
namespace Magento\CustomerGraphQl\Model\Resolver\CacheKey\FactorProvider;
99

1010
use Magento\GraphQl\Model\Query\ContextInterface;
11-
use Magento\GraphQlResolverCache\Model\Resolver\Result\CacheKey\GenericFactorInterface;
11+
use Magento\GraphQlResolverCache\Model\Resolver\Result\CacheKey\GenericFactorProviderInterface;
1212

1313
/**
1414
* Provides logged-in status as a factor to use in the cache key for resolver cache.
1515
*/
16-
class IsLoggedIn implements GenericFactorInterface
16+
class IsLoggedIn implements GenericFactorProviderInterface
1717
{
1818
private const NAME = "IS_LOGGED_IN";
1919

app/code/Magento/CustomerGraphQl/Model/Resolver/CacheKey/FactorProvider/ParentCustomerEntityId.php renamed to app/code/Magento/CustomerGraphQl/Model/Resolver/CacheKey/FactorProvider/ParentCustomerEntityIdProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99

1010
use Magento\Customer\Api\Data\CustomerInterface;
1111
use Magento\GraphQl\Model\Query\ContextInterface;
12-
use Magento\GraphQlResolverCache\Model\Resolver\Result\CacheKey\ParentValueFactorInterface;
12+
use Magento\GraphQlResolverCache\Model\Resolver\Result\CacheKey\ParentValueFactorProviderInterface;
1313

1414
/**
1515
* Provides customer id from the parent resolved value as a factor to use in the cache key for resolver cache.
1616
*/
17-
class ParentCustomerEntityId implements ParentValueFactorInterface
17+
class ParentCustomerEntityIdProvider implements ParentValueFactorProviderInterface
1818
{
1919
/**
2020
* Factor name.

app/code/Magento/GraphQlResolverCache/Model/Resolver/Result/CacheKey/Calculator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class Calculator
2929
private $factorProviders;
3030

3131
/**
32-
* @var GenericFactorInterface[]
32+
* @var GenericFactorProviderInterface[]
3333
*/
3434
private $factorProviderInstances;
3535

@@ -103,7 +103,7 @@ private function getFactors(?array $parentData): array
103103
$factors = [];
104104
$context = $this->contextFactory->get();
105105
foreach ($this->factorProviderInstances as $factorProvider) {
106-
if ($factorProvider instanceof ParentValueFactorInterface && is_array($parentData)) {
106+
if ($factorProvider instanceof ParentValueFactorProviderInterface && is_array($parentData)) {
107107
// preprocess data if the data was fetched from cache and has reference key
108108
// and the factorProvider expects processed data (original data from resolver)
109109
if (isset($parentData[ValueProcessorInterface::VALUE_PROCESSING_REFERENCE_KEY])

app/code/Magento/GraphQlResolverCache/Model/Resolver/Result/CacheKey/GenericFactorInterface.php renamed to app/code/Magento/GraphQlResolverCache/Model/Resolver/Result/CacheKey/GenericFactorProviderInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
/**
1313
* Interface for key factors that are used to calculate the resolver cache key.
1414
*/
15-
interface GenericFactorInterface
15+
interface GenericFactorProviderInterface
1616
{
1717
/**
1818
* Name of the cache key factor.

app/code/Magento/GraphQlResolverCache/Model/Resolver/Result/CacheKey/ParentValueFactorInterface.php renamed to app/code/Magento/GraphQlResolverCache/Model/Resolver/Result/CacheKey/ParentValueFactorProviderInterface.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
/**
1313
* Interface for key factors that are used to calculate the resolver cache key basing on parent value.
1414
*/
15-
interface ParentValueFactorInterface
15+
interface ParentValueFactorProviderInterface
1616
{
1717
/**
1818
* Name of the cache key factor.
@@ -26,11 +26,9 @@ public function getFactorName(): string;
2626
*
2727
* Must return true if any:
2828
* - original resolved data is required to resolve key factor
29-
* - parent resolver cache does not exist (yet)
3029
*
3130
* Can return false if any:
32-
* - parent resolver cache exists AND key factor can be resolved from deserialized unprocessed cached value
33-
* - key factor is one of or combination of the fields exposed in graphql schema
31+
* - key factor can be resolved from unprocessed cached value
3432
*
3533
* @return bool
3634
*/

app/code/Magento/StoreGraphQl/Model/Resolver/CacheKey/FactorProvider/Currency.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
namespace Magento\StoreGraphQl\Model\Resolver\CacheKey\FactorProvider;
99

1010
use Magento\GraphQl\Model\Query\ContextInterface;
11-
use Magento\GraphQlResolverCache\Model\Resolver\Result\CacheKey\GenericFactorInterface;
11+
use Magento\GraphQlResolverCache\Model\Resolver\Result\CacheKey\GenericFactorProviderInterface;
1212

1313
/**
1414
* Provides currency code as a factor to use in the resolver cache key.
1515
*/
16-
class Currency implements GenericFactorInterface
16+
class Currency implements GenericFactorProviderInterface
1717
{
1818
private const NAME = "CURRENCY";
1919

app/code/Magento/StoreGraphQl/Model/Resolver/CacheKey/FactorProvider/Store.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
namespace Magento\StoreGraphQl\Model\Resolver\CacheKey\FactorProvider;
99

1010
use Magento\GraphQl\Model\Query\ContextInterface;
11-
use Magento\GraphQlResolverCache\Model\Resolver\Result\CacheKey\GenericFactorInterface;
11+
use Magento\GraphQlResolverCache\Model\Resolver\Result\CacheKey\GenericFactorProviderInterface;
1212

1313
/**
1414
* Provides store code as a factor to use in the resolver cache key.
1515
*/
16-
class Store implements GenericFactorInterface
16+
class Store implements GenericFactorProviderInterface
1717
{
1818
private const NAME = "STORE";
1919

0 commit comments

Comments
 (0)