@shopify/react-graphql
Advanced tools
Comparing version 0.0.0-snapshot-20220623162708 to 0.0.0-snapshot-20220629200129
@@ -7,2 +7,3 @@ 'use strict'; | ||
var apolloClient$1 = require('apollo-client'); | ||
var isEqual = require('fast-deep-equal'); | ||
var reactEffect = require('@shopify/react-effect'); | ||
@@ -12,3 +13,12 @@ var apolloClient = require('./apollo-client.js'); | ||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
var isEqual__default = /*#__PURE__*/_interopDefaultLegacy(isEqual); | ||
/* eslint react-hooks/rules-of-hooks: off */ | ||
const { | ||
prototype: { | ||
hasOwnProperty | ||
} | ||
} = Object; | ||
function useQuery(queryOrAsyncQuery, ...optionsPart) { | ||
@@ -76,2 +86,3 @@ const [options = {}] = optionsPart; | ||
let subscription; | ||
let previousError; | ||
@@ -84,17 +95,36 @@ const invalidateCurrentResult = () => { | ||
function invalidateErrorResult() { | ||
unsubscribe(); | ||
function invalidateErrorResult(error) { | ||
const lastError = queryObservable.getLastError(); | ||
const lastResult = queryObservable.getLastResult(); | ||
queryObservable.resetLastResults(); | ||
subscribe(); | ||
Object.assign(queryObservable, { | ||
lastError, | ||
lastResult | ||
}); | ||
invalidateCurrentResult(); | ||
unsubscribe(); | ||
try { | ||
queryObservable === null || queryObservable === void 0 ? void 0 : queryObservable.resetLastResults(); | ||
subscribe(); | ||
} finally { | ||
Object.assign(queryObservable, { | ||
lastError, | ||
lastResult | ||
}); | ||
} | ||
if (!hasOwnProperty.call(error, 'graphQLErrors')) { | ||
// The error is not a GraphQL error | ||
throw error; | ||
} | ||
if (!previousError || !isEqual__default["default"](error, previousError)) { | ||
invalidateCurrentResult(); | ||
} | ||
previousError = error; | ||
} | ||
function subscribe() { | ||
subscription = queryObservable.subscribe(invalidateCurrentResult, invalidateErrorResult); | ||
subscription = queryObservable.subscribe(() => { | ||
previousError = undefined; | ||
invalidateCurrentResult(); | ||
}, error => { | ||
invalidateErrorResult(error); | ||
}); | ||
} | ||
@@ -101,0 +131,0 @@ |
{ | ||
"name": "@shopify/react-graphql", | ||
"version": "0.0.0-snapshot-20220623162708", | ||
"version": "0.0.0-snapshot-20220629200129", | ||
"license": "MIT", | ||
@@ -38,3 +38,4 @@ "description": "Tools for creating type-safe and asynchronous GraphQL components for React", | ||
"apollo-link": ">=1.0.0 <2.0.0", | ||
"graphql-typed": "^2.0.0" | ||
"graphql-typed": "^2.0.0", | ||
"fast-deep-equal": "^3.1.3" | ||
}, | ||
@@ -41,0 +42,0 @@ "devDependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
86733
1201
14
+ Addedfast-deep-equal@^3.1.3
+ Addedfast-deep-equal@3.1.3(transitive)