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

feat: add perspective parameter #224

Merged
merged 3 commits into from
May 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sanity/client",
"version": "6.0.1",
"version": "6.1.0-perspective.2",
"description": "Client for retrieving, creating and patching data from Sanity.io",
"keywords": [
"sanity",
Expand Down
3 changes: 3 additions & 0 deletions src/data/dataMethods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,9 @@ export function _requestObservable<R>(
if (config.resultSourceMap) {
options.query = {resultSourceMap: true, ...options.query}
}
if (typeof config.perspective === 'string' && config.perspective !== 'all') {
options.query = {perspective: config.perspective, ...options.query}
}
}

const reqOptions = requestOptions(
Expand Down
4 changes: 4 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export interface ClientConfig {
/** @defaultValue true */
useCdn?: boolean
token?: string
perspective?: 'previewDrafts' | 'published' | 'all'
apiHost?: string
apiVersion?: string
proxy?: string
Expand Down Expand Up @@ -67,6 +68,9 @@ export interface ClientConfig {
*/
requester?: Requester

/**
* Adds a `resultSourceMap` key to the API response, with the type `ContentSourceMap`
*/
resultSourceMap?: boolean
}

Expand Down