react-datocms
Advanced tools
Comparing version 1.3.0 to 1.4.0
@@ -37,3 +37,3 @@ export declare type UpdateData<QueryResult> = { | ||
/** The fetch function to use to perform the registration query */ | ||
fetch?: (input: RequestInfo, init?: RequestInit) => Promise<Response>; | ||
fetcher?: (input: RequestInfo, init?: RequestInit) => Promise<Response>; | ||
/** The base URL to use to perform the query (defaults to `https://graphql-listen.datocms.com`) */ | ||
@@ -40,0 +40,0 @@ baseUrl?: string; |
@@ -63,3 +63,3 @@ "use strict"; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var query, token, variables, preview, environment, customFetch, onStatusChange, onUpdate, onChannelError, customReconnectionPeriod, customBaseUrl, fetch, reconnectionPeriod, baseUrl, waitAndReconnect, registrationId, req, registration, e_1; | ||
var query, token, variables, preview, environment, customFetcher, onStatusChange, onUpdate, onChannelError, customReconnectionPeriod, customBaseUrl, fetcher, reconnectionPeriod, baseUrl, waitAndReconnect, registrationId, req, registration, e_1; | ||
var _this = this; | ||
@@ -69,4 +69,4 @@ return __generator(this, function (_a) { | ||
case 0: | ||
query = options.query, token = options.token, variables = options.variables, preview = options.preview, environment = options.environment, customFetch = options.fetch, onStatusChange = options.onStatusChange, onUpdate = options.onUpdate, onChannelError = options.onChannelError, customReconnectionPeriod = options.reconnectionPeriod, customBaseUrl = options.baseUrl; | ||
fetch = customFetch || window.fetch; | ||
query = options.query, token = options.token, variables = options.variables, preview = options.preview, environment = options.environment, customFetcher = options.fetcher, onStatusChange = options.onStatusChange, onUpdate = options.onUpdate, onChannelError = options.onChannelError, customReconnectionPeriod = options.reconnectionPeriod, customBaseUrl = options.baseUrl; | ||
fetcher = customFetcher || window.fetch; | ||
reconnectionPeriod = customReconnectionPeriod || 1000; | ||
@@ -88,3 +88,3 @@ baseUrl = customBaseUrl || "https://graphql-listen.datocms.com"; | ||
_a.trys.push([1, 4, , 5]); | ||
return [4 /*yield*/, fetch(endpointFactory({ baseUrl: baseUrl, preview: preview, environment: environment }), { | ||
return [4 /*yield*/, fetcher(endpointFactory({ baseUrl: baseUrl, preview: preview, environment: environment }), { | ||
headers: { | ||
@@ -91,0 +91,0 @@ Authorization: "Bearer " + token, |
@@ -20,3 +20,3 @@ import { ChannelErrorData } from "../subscribeToQuery"; | ||
/** The fetch function to use to perform the registration query */ | ||
fetch?: (input: RequestInfo, init?: RequestInit) => Promise<Response>; | ||
fetcher?: (input: RequestInfo, init?: RequestInit) => Promise<Response>; | ||
/** The base URL to use to perform the query (defaults to `https://graphql-listen.datocms.com`) */ | ||
@@ -23,0 +23,0 @@ baseUrl?: string; |
@@ -43,3 +43,3 @@ "use strict"; | ||
function useQuerySubscription(options) { | ||
var initialData = options.initialData, enabled = options.enabled, preview = options.preview, query = options.query, token = options.token, variables = options.variables, environment = options.environment, fetch = options.fetch, reconnectionPeriod = options.reconnectionPeriod; | ||
var initialData = options.initialData, enabled = options.enabled, preview = options.preview, query = options.query, token = options.token, variables = options.variables, environment = options.environment, fetcher = options.fetcher, reconnectionPeriod = options.reconnectionPeriod; | ||
var _a = react_1.useState(null), error = _a[0], setError = _a[1]; | ||
@@ -49,3 +49,3 @@ var _b = react_1.useState(null), data = _b[0], setData = _b[1]; | ||
use_deep_compare_effect_1.useDeepCompareEffectNoCheck(function () { | ||
if (!enabled) { | ||
if (enabled === false) { | ||
return function () { | ||
@@ -66,3 +66,3 @@ // we don't have to perform any uninstall | ||
environment: environment, | ||
fetch: fetch, | ||
fetcher: fetcher, | ||
reconnectionPeriod: reconnectionPeriod, | ||
@@ -69,0 +69,0 @@ onStatusChange: function (status) { |
{ | ||
"name": "react-datocms", | ||
"version": "1.3.0", | ||
"version": "1.4.0", | ||
"types": "dist/index.d.ts", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -78,3 +78,3 @@ # react-datocms | ||
| ------------------ | ----------------------------------------------------------------------------------- | ------------------ | ----------------------------------------------------------------- | ------------------------------------ | | ||
| enabled | boolean | :x: | Whether the subscription has to be performed or not | false | | ||
| enabled | boolean | :x: | Whether the subscription has to be performed or not | true | | ||
| query | string | :white_check_mark: | The GraphQL query to subscribe | | | ||
@@ -81,0 +81,0 @@ | token | string | :white_check_mark: | DatoCMS API token to use | | |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
69040
0