Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The query result yielded cache contexts Error is thrown when tmgmt_content is enabled. #585

Closed
awm086 opened this issue Apr 25, 2018 · 1 comment

Comments

@awm086
Copy link
Contributor

awm086 commented Apr 25, 2018

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.
But it seems that tmgmt_content_entity_access is adding the cache context appropriately. And I believe this is may be a graphQl issue.
To Reproduce:

  • enable graphql
  • enable tgmgt_content
  • grant anonymous users to execute graphql queries
  • Execute any graph ql query as anonymous user.
@pmelab
Copy link
Contributor

pmelab commented Apr 26, 2018

This is a duplicate of #584

@pmelab pmelab closed this as completed Apr 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants