Skip to content

Commit dcca338

Browse files
committed
Fix GraphQL schema @cache declaration argument typo
The `@cache` directive argument name is `cacheable`, not `cachable`. Reference line 1 of the method `\Magento\GraphQlCache\Model\CacheableQueryHandler::handleCacheFromResolverResponse`: ``` public function handleCacheFromResolverResponse(array $resolvedValue, array $cacheAnnotation) : void { $cacheable = $cacheAnnotation['cacheable'] ?? true; $cacheIdentityClass = $cacheAnnotation['cacheIdentity'] ?? ''; if ($this->request instanceof Http && $this->request->isGet() && !empty($cacheIdentityClass)) { $cacheIdentity = $this->identityPool->get($cacheIdentityClass); $cacheTags = $cacheIdentity->getIdentities($resolvedValue); $this->cacheableQuery->addCacheTags($cacheTags); } else { $cacheable = false; } $this->setCacheValidity($cacheable); } ``` In the context of Magento, the directive declaration is only for documentation purposes. The directive itself is used by the GraphQL API implementation, but the directive declaration is not. As such this PR is backward compatible. The effect is only that, once merged, valid directive are no longer highlighted as an error in PHPStorm.
1 parent 0714971 commit dcca338

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

app/code/Magento/GraphQl/etc/schema.graphqls

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ directive @resolver(class: String="") on QUERY
3636
| ENUM_VALUE
3737
| INPUT_OBJECT
3838
| INPUT_FIELD_DEFINITION
39-
39+
4040
directive @typeResolver(class: String="") on INTERFACE | OBJECT
4141

42-
directive @cache(cacheIdentity: String="" cachable: Boolean=true) on QUERY
42+
directive @cache(cacheIdentity: String="" cacheable: Boolean=true) on QUERY
4343

4444
type Query {
4545
}

0 commit comments

Comments
 (0)