feat(next-drupal): next revalidate options
Adds next revalidate options to resource-methods and custom fetch.
This pull request is for: (mark with an "x")
- [ ]
examples/* - [ ]
modules/next - [x]
packages/next-drupal - [ ]
starters/basic-starter - [ ]
starters/graphql-starter - [ ]
starters/pages-starter - [ ] Other
GitHub Issue: #761
- [x] I need help adding tests. (mark with an "x") Code changes need test coverage. If you don't know how to make tests, check this box to ask for help.
Describe your changes
I've extended the custom fetch function to accept the next revalidation options.
-
fetch("https://...", { next: { revalidate: false | 0 | number } }) -
fetch("https://...", { next: { tags: ['node:1', 'tag:2'] } })
I've added the next option to the following resource-methods:
getResource
getResourceByPath
getResourceCollection
getResourceCollectionPathSegments
translatePath
getIndex
getMenu
getView
getSearchIndex
It might be necessary to add it to CRUD methods or others, but I'll wait for feedback first.
I've added some unitary tests as well but might need refinement.
Someone is attempting to deploy a commit to the Chapter Three Team on Vercel.
A member of the Team first needs to authorize it.
@backlineint I've made the correction to the FetchOptions interface. So it would be ready to merge. As you commented, there are a few steps to follow in further tickets:
- Update starters
- Add
cacheoption to methods to follow the next js fetch options. - Check if it's relevant to extend this
next: {revalidate}option to another CRUD methods. See main PR description to check which methods support revalidate options for now. - Update the docs again to add information to the corresponding methods about the new allowed parameter.
Thanks!