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-bust GraphQL requests made with graphQLFetch() #227

Merged
merged 2 commits into from
Mar 10, 2022

Conversation

angeloashmore
Copy link
Member

Types of changes

  • Chore (a non-breaking change which is related to package maintenance)
  • Bug fix (a non-breaking change which fixes an issue)
  • New feature (a non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Description

This PR cache-busts GraphQL requests made with graphQLFetch(). It does this by including the request's ref as a URL parameter.

The Prismic GraphQL API ignores the ref parameter; the API reads the ref from a header named Prismic-ref.

Without this PR, re-running a query may return a locally cached response, even when after the ref changes. This happens because caches typically do not take into account headers when caching requests.

Related: prismicio/apollo-link-prismic#39

Checklist:

  • My change requires an update to the official documentation.
  • All TSDoc comments are up-to-date and new ones have been added where necessary.
  • All new and existing tests are passing.

🕸️

@angeloashmore angeloashmore changed the title fix: cache-bust GraphQL requests made with graphQLFetch() by including a ref URL parameter fix: cache-bust GraphQL requests made with graphQLFetch() Mar 10, 2022
@codecov-commenter
Copy link

codecov-commenter commented Mar 10, 2022

Codecov Report

Merging #227 (c26b494) into master (4d90494) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #227   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           23        23           
  Lines          359       360    +1     
  Branches        67        67           
=========================================
+ Hits           359       360    +1     
Impacted Files Coverage Δ
src/client.ts 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4d90494...c26b494. Read the comment docs.

@github-actions
Copy link

github-actions bot commented Mar 10, 2022

size-limit report 📦

Path Size
dist/index.js 4.03 KB (+0.2% 🔺)
dist/index.cjs 6.86 KB (+0.15% 🔺)

@angeloashmore
Copy link
Member Author

Published as an alpha at v6.4.1-alpha.1.

@angeloashmore angeloashmore merged commit 894e7a8 into master Mar 10, 2022
@angeloashmore angeloashmore deleted the aa/graphql-cache-bust branch March 10, 2022 18:37
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