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

Update api/revalidate/route.ts in starters to support revalidateTag #807

Closed
backlineint opened this issue Oct 22, 2024 · 0 comments · Fixed by #820
Closed

Update api/revalidate/route.ts in starters to support revalidateTag #807

backlineint opened this issue Oct 22, 2024 · 0 comments · Fixed by #820
Assignees
Labels
enhancement New feature or request triage A new issue that needs triage

Comments

@backlineint
Copy link
Collaborator

backlineint commented Oct 22, 2024

Package

basic-starter

Describe the feature request

#784 introduced revalidate options for the fetch methods used by the Next Drupal client, including tags. To simplify the process of invalidating these tags, we should update the revalidation API route (api/revalidate/route.ts) in our starters to also allow tags to be invalidated, rather than only paths.

Describe the solution you'd like

api/revalidate/route.ts will also accept a tags parameter which would be a comma separated list of cache tag values.

With this change:

  • If a path is provided, it will be invalidated using revalidatePath.
  • If tags are provided, they will be invalidated using revalidateTag
  • I don't think this is essential, but it seems like this route should also be able to handle cases where both a path and tags are provided. In that situation they would both be invalidated.

The API route should continue to allow both GET and POST methods.

This change should also be made to the related API route in the GraphQL starter.

Describe alternatives you've considered

This can be handled with a custom API route today, but having this available in the starters out of the box would be ideal.

Additional context

A related issue will update the Next Drupal module to call this API endpoint when tags are invalidated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request triage A new issue that needs triage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants