prismic-client
prismic-client copied to clipboard
refactor: simplify ref management
Resolves: N/A
Description
This PR simplifies the client's internal ref state management.
Public API change
Function-based ref specifiers now accept a context object with the accessToken and fetchOptions parameters provided to the method or client.
In the following example, params contains accessToken and fetchOptions, perfect for passing to another client method. It can also be destructured and used individually.
client.queryContentFromRef(async (params) => {
const release = await this.getReleaseByLabel(label, params)
return release.ref
})
This change was primarily made for some internal changes, but it doesn't hurt to pass it along to the user-facing function.
Checklist
- [ ] A comprehensive Linear ticket, providing sufficient context and details to facilitate the review of the PR, is linked to the PR.
- [ ] If my changes require tests, I added them.
- [ ] If my changes affect backward compatibility, it has been discussed.
- [ ] If my changes require an update to the CONTRIBUTING.md guide, I updated it.
Preview
How to QA [^1]
[^1]: Please use these labels when submitting a review: :question: #ask: Ask a question. :bulb: #idea: Suggest an idea. :warning: #issue: Strongly suggest a change. :tada: #nice: Share a compliment.