Skip to content

Commit

Permalink
feat: add perspective parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
stipsan committed May 12, 2023
1 parent 1396414 commit f6cc26d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
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

0 comments on commit f6cc26d

Please sign in to comment.