@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.cjs CHANGED
@@ -15,7 +15,7 @@ function _interopDefaultCompat(e) {
15
15
  }
16
16
  var polyfilledEventSource__default = /*#__PURE__*/_interopDefaultCompat(polyfilledEventSource);
17
17
  var name = "@sanity/client";
18
- var version = "0.0.0-dev.2";
18
+ var version = "0.0.0-dev.3";
19
19
  const middleware = [middleware$1.debug({
20
20
  verbose: true,
21
21
  namespace: "sanity:client"
@@ -680,9 +680,23 @@ const indexBy = (docs, attr) => docs.reduce((indexed, doc) => {
680
680
  return indexed;
681
681
  }, /* @__PURE__ */Object.create(null));
682
682
  const getQuerySizeLimit = 11264;
683
- function _fetch(client, httpRequest, query, params) {
683
+ function _fetch(client, httpRequest, query, _params) {
684
684
  let options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
685
685
  const mapResponse = options.filterResponse === false ? res => res : res => res.result;
686
+ let params = _params;
687
+ const {
688
+ unstable_overlayDrafts,
689
+ apiVersion
690
+ } = client.config();
691
+ if (unstable_overlayDrafts) {
692
+ if (apiVersion !== "X") {
693
+ console.error("You need to set `apiVersion` to `X` to use `unstable_overlayDrafts");
694
+ }
695
+ params = {
696
+ ...params,
697
+ draftMode: true
698
+ };
699
+ }
686
700
  return _dataRequest(client, httpRequest, "query", {
687
701
  query,
688
702
  params
@@ -803,18 +817,6 @@ function _requestObservable(client, httpRequest, options) {
803
817
  ...options.query
804
818
  };
805
819
  }
806
- if (config.unstable_overlayDrafts) {
807
- if (config.apiVersion !== "X") {
808
- console.error("You need to set `apiVersion` to `X` to use `unstable_overlayDrafts");
809
- }
810
- options.query = {
811
- ...options.query,
812
- params: {
813
- ...(options.query.params || {}),
814
- draftMode: true
815
- }
816
- };
817
- }
818
820
  const reqOptions = requestOptions(config, Object.assign({}, options, {
819
821
  url: _getUrl(client, uri, useCdn)
820
822
  }));