ExamGecko
Question list
Search
Search

List of questions

Search

Related questions











Question 23 - AD0-E722 discussion

Report
Export

An Architect working on a headless Adobe Commerce project creates a new customer attribute named my_attribute. Based on the attribute value of the customer, the results of GraphQI queries are modified using a plugin. The frontend application is communicating with Adobe Commerce through Varnish by Fastly. which is already caching the queries that will be modified. The Adobe Commerce Fastly extension is installed, and no other modifications are made to the application.

Which steps should the Architect take to make sure the vcl_hash function of Varnish also considers the newly created attribute?

A.
Create a new ClaSS inheriting from Magento\GraphQlCache\Model\CacheId\CacheIdFactorProvidftrInterface and returning the Value of my_attribute from the getFactorValue function and my_attribute from the getFactorName function. Then add this class through Dl to the idFactorProviders array of Magento\GraphQlCache\Model\CacheId\CacheIdCalculator.
Answers
A.
Create a new ClaSS inheriting from Magento\GraphQlCache\Model\CacheId\CacheIdFactorProvidftrInterface and returning the Value of my_attribute from the getFactorValue function and my_attribute from the getFactorName function. Then add this class through Dl to the idFactorProviders array of Magento\GraphQlCache\Model\CacheId\CacheIdCalculator.
B.
Create a new class inheriting from Magento\Framework\GraphQi\Query\Resolver\identityinterfaca and returning the value of my_attribute from the getidentities function. Then specify a ecache(cacheidentity: Path\\To\\identityclass) directive for each GraphQL query to include the newly created IdentityClass to each query that adds the cache tags for each customer.
Answers
B.
Create a new class inheriting from Magento\Framework\GraphQi\Query\Resolver\identityinterfaca and returning the value of my_attribute from the getidentities function. Then specify a ecache(cacheidentity: Path\\To\\identityclass) directive for each GraphQL query to include the newly created IdentityClass to each query that adds the cache tags for each customer.
C.
Create a new class inheriting from Magento\customer\customerData\stctionSourceinterface and returning the value of my_attribute from the getSectionData function. Then add this ClaSS through the sectionSourceMap array Of Magento\Customer\CustomerData\SectionPoolInterface.
Answers
C.
Create a new class inheriting from Magento\customer\customerData\stctionSourceinterface and returning the value of my_attribute from the getSectionData function. Then add this ClaSS through the sectionSourceMap array Of Magento\Customer\CustomerData\SectionPoolInterface.
Suggested answer: A

Explanation:

To make sure the vcl_hash function of Varnish considers the newly created attribute, the Architect needs to do the following steps:

Create a new class that implements the Magento\GraphQlCache\Model\CacheId\CacheIdFactorProviderInterface interface. This interface defines two methods: getFactorName and getFactorValue. The getFactorName method should return the name of the attribute, in this case, my_attribute.The getFactorValue method should return the value of the attribute for the current customer, which can be obtained from the customer session or customer repository1.

Add this class to the idFactorProviders array of Magento\GraphQlCache\Model\CacheId\CacheIdCalculator through dependency injection. The CacheIdCalculator is responsible for generating a cache ID for each GraphQL request based on the factors provided by the idFactorProviders.By adding the new class to this array, the Architect ensures that the cache ID will include the value of my_attribute1.

The cache ID is then used by Varnish to hash and lookup the cached response for each request.By including my_attribute in the cache ID, the Architect ensures that Varnish will serve different responses based on the attribute value of the customer2.Reference:

Magento_GraphQlCache module | Magento 2 Developer Documentation

Varnish caching | Adobe Commerce 2.4 User Guide - Magento

asked 02/10/2024
Laura Archilla
36 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first