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

fix(dataproducer): CurrentUser result is uncacheable #1417

Open
wants to merge 3 commits into
base: 8.x-4.x
Choose a base branch
from

Conversation

pfrenssen
Copy link

Fixes #1351

Copy link
Contributor

@klausi klausi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot, approach makes sense. Only the test is not correct to me.

Please continue this work in a new merge request on drupal.org, we recently moved development there to assign issue credits there. https://www.drupal.org/project/issues/graphql

@@ -72,6 +72,11 @@ graphql.settings:
label: "GraphQL Settings"
mapping:
# @todo Remove in GraphQL 5.
dataproducer_allow_current_user_caching:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need this setting. We can add caching, as long as we achieve the same behavior this will not be a compatibility break.

/**
* {@inheritdoc}
*/
protected function executeDataProducer($id, array $contexts = []) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but this does not actually test the caching.

We need to test 2 things:

  1. Repeated calls to get the current user return a cached result
  2. when the user cache context is cleared you get an uncached result

I think just calling the dataproducer is not enough. Check out ResultCacheTest which does some unholy mocking, but should be the right approach.

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

Successfully merging this pull request may close these issues.

Using the current_user data producer makes response uncacheable
2 participants