Closed t-heuser closed 1 year ago
Hi @oneserv-heuser ,
Thank you for opening this issue. The return of the available methods depends on the amount and currency (see: https://github.com/mollie/magento2/blob/master/GraphQL/Resolver/General/MolliePaymentMethods.php#L64-L70) so it's a bit hard to cache this.
We're requesting all available payment methods via GraphQl for every visitor in our store to show them our payment methods. That results in a lot of requests to the Mollie API which could be prevented by adding the cache identity.
You mean at the checkout right? Or do you use this to show images in eg a footer?
Maybe it's possible if you include the currency and amount in the cache tag? We're never passing any parameters to the query which means it's always 10 and EUR as defined here: https://github.com/mollie/magento2/blob/7fe08fa9f768f0f3e48358319b52557be777f58d/GraphQL/Resolver/General/MolliePaymentMethods.php#L54-L55
The payment methods returned from the query molliePaymentMethods
are shown in the footer, for the checkout we're requesting the payment methods directly from the cart
HI @oneserv-heuser ,
This is unintended usage of the endpoint, as this is meant to fetch the methods for a quote (based on the value of the quote) and is not meant to be hit on every visit to get the active methods from Mollie. If you continue using it unintendedly, we recommend implementing a cache solution for this yourself.
Hi @Frank-Magmodules, thank you four your feedback. What is the intended method to fetch the available payment methods to show to every customer outside of the checkout?
And what is the use of the extra query molliePaymentMethods
if the use case is to fetch the methods for a quote if you can just fetch the payment methods directly from the quote?
Hi @oneserv-heuser , happy to share that we have just added this feature request to the latest release!
Describe the new feature
Add a caching Identity for the query
molliePaymentMethods
so that results for the query can be cached.Describe the solution to be implemented
Backend changes A cache Identity must be added the query
molliePaymentMethods
to implement caching. The relevant documentation can be found here:Additional context At the moment with every call on the
molliePaymentMethods
query a request is send via the mollie API to get all available payment methods from the mollie account. Those methods are then processed to apply the Magento Configuration for the payment methods. At the moment the query result is not cached, as the documentation states, "A query without a cacheIdentity will not be cached.".Adding a cache identity would prevent the request of the payment methods for every query call. We're requesting all available payment methods via GraphQl for every visitor in our store to show them our payment methods. That results in a lot of requests to the Mollie API which could be prevented by adding the cache identity.