Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@swan-io/graphql-client

Package Overview
Dependencies
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@swan-io/graphql-client - npm Package Compare versions

Comparing version 0.1.0-alpha10 to 0.1.0-alpha11

31

dist/index.js

@@ -1188,10 +1188,11 @@ 'use strict';

const [stableQuery] = react.useState(query);
const [stableVariables, setStableVariables] = react.useState(variables);
const [stableVariables, setStableVariables] = react.useState([variables, variables]);
react.useEffect(() => {
if (!deepEqual(stableVariables, variables)) {
setStableVariables(variables);
const [providedVariables] = stableVariables;
if (!deepEqual(providedVariables, variables)) {
setStableVariables([variables, variables]);
}
}, [stableVariables, variables]);
const getSnapshot = react.useCallback(() => {
return client.readFromCache(stableQuery, stableVariables);
return client.readFromCache(stableQuery, stableVariables[1]);
}, [client, stableQuery, stableVariables]);

@@ -1212,3 +1213,3 @@ const data = react.useSyncExternalStore(

}
const request = client.query(stableQuery, stableVariables, { optimize });
const request = client.query(stableQuery, stableVariables[1], { optimize });
return () => request.cancel();

@@ -1219,3 +1220,3 @@ }, [client, suspense, optimize, stableQuery, stableVariables]);

setIsRefreshing(true);
return client.request(stableQuery, stableVariables).tap(() => setIsRefreshing(false));
return client.request(stableQuery, stableVariables[1]).tap(() => setIsRefreshing(false));
}, [client, stableQuery, stableVariables]);

@@ -1225,3 +1226,4 @@ const [isReloading, setIsReloading] = react.useState(false);

setIsReloading(true);
return client.request(stableQuery, stableVariables).tap(() => setIsReloading(false));
setStableVariables(([stable]) => [stable, stable]);
return client.request(stableQuery, stableVariables[0]).tap(() => setIsReloading(false));
}, [client, stableQuery, stableVariables]);

@@ -1231,7 +1233,18 @@ const isLoading = isRefreshing || isReloading || asyncData.isLoading();

if (suspense && asyncDataToExpose.isLoading()) {
throw client.query(stableQuery, stableVariables, { optimize }).toPromise();
throw client.query(stableQuery, stableVariables[1], { optimize }).toPromise();
}
return [asyncDataToExpose, { isLoading, refresh, reload }];
const setVariables = react.useCallback((variables2) => {
setStableVariables((prev) => {
const [prevStable, prevFinal] = prev;
const nextFinal = { ...prevFinal, ...variables2 };
if (!deepEqual(prevFinal, nextFinal)) {
return [prevStable, nextFinal];
} else {
return prev;
}
});
}, []);
return [asyncDataToExpose, { isLoading, refresh, reload, setVariables }];
};
//# sourceMappingURL=out.js.map
//# sourceMappingURL=index.js.map

@@ -11,3 +11,3 @@ import { AsyncData, Result, Future } from '@swan-io/boxed';

};
type Query<Data> = readonly [
type Query<Data, Variables> = readonly [
AsyncData<Result<Data, ClientError>>,

@@ -18,6 +18,7 @@ {

refresh: () => Future<Result<Data, ClientError>>;
setVariables: (variables: Partial<Variables>) => void;
}
];
declare const useQuery: <Data, Variables>(query: TypedDocumentNode<Data, Variables>, variables: Variables, { suspense, optimize }?: QueryConfig) => Query<Data>;
declare const useQuery: <Data, Variables>(query: TypedDocumentNode<Data, Variables>, variables: Variables, { suspense, optimize }?: QueryConfig) => Query<Data, Variables>;
export { type Query, type QueryConfig, useQuery };
{
"name": "@swan-io/graphql-client",
"version": "0.1.0-alpha10",
"version": "0.1.0-alpha11",
"license": "MIT",

@@ -5,0 +5,0 @@ "description": "A simple, typesafe GraphQL client for React",

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc