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 cache key when the user is not authenticated #843

Merged
merged 9 commits into from
Jul 16, 2019
Merged

Fix cache key when the user is not authenticated #843

merged 9 commits into from
Jul 16, 2019

Conversation

hosmelq
Copy link
Contributor

@hosmelq hosmelq commented Jun 28, 2019

  • Added or updated tests
  • Added Docs for all relevant versions
  • Updated the changelog

Related Issue/Intent

@cache(private: true) fails when the user is not authenticated.

Changes

Check if the user is authenticated before create the cache key.

Breaking changes

None

@hosmelq hosmelq changed the title fix cache key when not auth user is present Fix cache key when the user is not authenticated Jun 28, 2019
@spawnia
Copy link
Collaborator

spawnia commented Jul 7, 2019

@hosmelq i am interested in the use case this solves. Can you give an example of when you would want this behaviour?

@hosmelq
Copy link
Contributor Author

hosmelq commented Jul 8, 2019

This is my schema.

type User {
  id: ID!
  ...
}

type Game {
  id: ID!
  viewerIsAMember: Boolean!
    @field(resolver: "App\\GraphQL\\Types\\Game@viewerIsAMember")
    @cache(maxAge: 300 private: true)
  ...
}

The viewerIsAMember field identifies if the authenticated user is part of the game but this game is accessible for not authenticated users too, for that reason I'm getting the error.

@spawnia
Copy link
Collaborator

spawnia commented Jul 8, 2019

Makes sense. Can you add a test case?

@spawnia spawnia merged commit d1263bf into nuwave:master Jul 16, 2019
@spawnia
Copy link
Collaborator

spawnia commented Jul 16, 2019

Thanks @hosmelq nice job.

@hosmelq hosmelq deleted the fix/cache-get-key branch July 16, 2019 17:36
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.

2 participants