@sanity/client 0.0.0-dev.2 → 0.0.0-dev.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ import { Observable, lastValueFrom } from 'rxjs';
4
4
  import { map, filter } from 'rxjs/operators';
5
5
  import polyfilledEventSource from '@sanity/eventsource';
6
6
  var name = "@sanity/client";
7
- var version = "0.0.0-dev.2";
7
+ var version = "0.0.0-dev.3";
8
8
  const middleware = [debug({
9
9
  verbose: true,
10
10
  namespace: "sanity:client"
@@ -669,9 +669,23 @@ const indexBy = (docs, attr) => docs.reduce((indexed, doc) => {
669
669
  return indexed;
670
670
  }, /* @__PURE__ */Object.create(null));
671
671
  const getQuerySizeLimit = 11264;
672
- function _fetch(client, httpRequest, query, params) {
672
+ function _fetch(client, httpRequest, query, _params) {
673
673
  let options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
674
674
  const mapResponse = options.filterResponse === false ? res => res : res => res.result;
675
+ let params = _params;
676
+ const {
677
+ unstable_overlayDrafts,
678
+ apiVersion
679
+ } = client.config();
680
+ if (unstable_overlayDrafts) {
681
+ if (apiVersion !== "X") {
682
+ console.error("You need to set `apiVersion` to `X` to use `unstable_overlayDrafts");
683
+ }
684
+ params = {
685
+ ...params,
686
+ draftMode: true
687
+ };
688
+ }
675
689
  return _dataRequest(client, httpRequest, "query", {
676
690
  query,
677
691
  params
@@ -792,18 +806,6 @@ function _requestObservable(client, httpRequest, options) {
792
806
  ...options.query
793
807
  };
794
808
  }
795
- if (config.unstable_overlayDrafts) {
796
- if (config.apiVersion !== "X") {
797
- console.error("You need to set `apiVersion` to `X` to use `unstable_overlayDrafts");
798
- }
799
- options.query = {
800
- ...options.query,
801
- params: {
802
- ...(options.query.params || {}),
803
- draftMode: true
804
- }
805
- };
806
- }
807
809
  const reqOptions = requestOptions(config, Object.assign({}, options, {
808
810
  url: _getUrl(client, uri, useCdn)
809
811
  }));