Skip to content

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

@backlineint

Description

@backlineint

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.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requesttriageA new issue that needs triage

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions