url.query_args:key cache context is breaking graphql queries

Created on 25 April 2018, about 6 years ago
Updated 24 November 2023, 7 months ago

graphql module checks for CacheContexts when queries are submitted :

if ($missing = array_diff($result->getCacheContexts(), $metadata->getCacheContexts())) {
        throw new \LogicException(sprintf(
          'The query result yielded cache contexts (%s) that were not part of the static query analysis.',
          implode(', ', $missing)
        ));
      }

And as soon as I enabled tgmgt_content, the exception above is thrown upon the execution of graphql query. It complains that a cache context "(url.query_args:key)" is missing. This context is being added by tmgmt_content_entity_access in :

/**
 * Implements hook_entity_access().
 */
function tmgmt_content_entity_access(\Drupal\Core\Entity\EntityInterface $entity, $operation, \Drupal\Core\Session\AccountInterface $account) {

    .....
  return $result->addCacheContexts(['url.query_args:key']);
}

commenting out return $result->addCacheContexts(['url.query_args:key']); fixes the issue.

I am not sure if it's graphql that is not handling the context properly. Or is it tmgmt_content that is not supposed to add the key context?

To Reproduce:
- enable graphql
- enable tgmgt_content
- grant anonymous users to execute graphql queries
- submit a graph ql query.

πŸ› Bug report
Status

Needs review

Version

1.0

Component

Source: Entity

Created by

πŸ‡ΊπŸ‡ΈUnited States awm

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024