Problem/Motivation

This is a continuation of Github issue #1351: Using the current_user data producer makes response uncacheable.

When using the current_user data producer the response becomes uncacheable. This is because of this line:

 $field_context->addCacheableDependency($this->currentUser); 

As $this->currentUser is an AccountProxy object which does not implement CacheableDependencyInterface, the addCacheableDependency() method in RefinableCacheableDependencyTrait will fall back to setting the max age to 0.

Proposed resolution

Add the user cache context manually.

Issue fork graphql-3552851

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

pfrenssen created an issue. See original summary.

pfrenssen’s picture

Assigned: Unassigned » pfrenssen
Issue tags: +Vienna2025

pfrenssen’s picture

Assigned: pfrenssen » Unassigned
Status: Active » Needs review
klausi’s picture

Status: Needs review » Fixed

Perfect, thanks a lot!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • klausi committed 3ce64fc5 on 5.x authored by pfrenssen
    fix(current:user): Correctly add cacheability metadata to the current...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.