New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@swan-io/graphql-client

Package Overview
Dependencies
Maintainers
1
Versions
46
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-alpha9 to 0.1.0-beta1

17

dist/cache/cache.d.ts

@@ -1,5 +0,3 @@

import * as graphql from 'graphql';
import { OperationDefinitionNode, DocumentNode } from '@0no-co/graphql.web';
import { Option, Result } from '@swan-io/boxed';
import { DocumentNode, OperationDefinitionNode } from "@0no-co/graphql.web";
import { Option, Result } from "@swan-io/boxed";
type CacheEntry = {

@@ -9,7 +7,7 @@ requestedKeys: Set<symbol>;

};
declare const getCacheKeyFromJson: (json: unknown) => Option<symbol>;
declare const getCacheKeyFromOperationNode: (operationNode: OperationDefinitionNode) => Option<symbol>;
declare class ClientCache {
export declare const getCacheKeyFromJson: (json: unknown) => Option<symbol>;
export declare const getCacheKeyFromOperationNode: (operationNode: OperationDefinitionNode) => Option<symbol>;
export declare class ClientCache {
cache: Map<symbol, CacheEntry>;
operationCache: Map<graphql.DocumentNode, Map<string, Option<Result<unknown, unknown>>>>;
operationCache: Map<import("graphql").DocumentNode, Map<string, Option<Result<unknown, unknown>>>>;
dump(): Map<symbol, CacheEntry>;

@@ -34,3 +32,2 @@ getOperationFromCache(documentNode: DocumentNode, variables: Record<string, unknown>): Option<Result<unknown, unknown>>;

}
export { ClientCache, getCacheKeyFromJson, getCacheKeyFromOperationNode };
export {};

@@ -1,9 +0,5 @@

import { DocumentNode } from '@0no-co/graphql.web';
import { Option, Result } from '@swan-io/boxed';
import { ClientCache } from './cache.js';
import 'graphql';
declare const readOperationFromCache: (cache: ClientCache, document: DocumentNode, variables: Record<string, unknown>) => Option<Result<unknown, unknown>>;
declare const optimizeQuery: (cache: ClientCache, document: DocumentNode, variables: Record<string, unknown>) => Option<DocumentNode>;
export { optimizeQuery, readOperationFromCache };
import { DocumentNode } from "@0no-co/graphql.web";
import { Option, Result } from "@swan-io/boxed";
import { ClientCache } from "./cache";
export declare const readOperationFromCache: (cache: ClientCache, document: DocumentNode, variables: Record<string, unknown>) => Option<Result<unknown, unknown>>;
export declare const optimizeQuery: (cache: ClientCache, document: DocumentNode, variables: Record<string, unknown>) => Option<DocumentNode>;

@@ -1,8 +0,3 @@

import { DocumentNode } from '@0no-co/graphql.web';
import { ClientCache } from './cache.js';
import 'graphql';
import '@swan-io/boxed';
declare const writeOperationToCache: (cache: ClientCache, document: DocumentNode, response: unknown, variables: Record<string, unknown>) => ClientCache;
export { writeOperationToCache };
import { DocumentNode } from "@0no-co/graphql.web";
import { ClientCache } from "./cache";
export declare const writeOperationToCache: (cache: ClientCache, document: DocumentNode, response: unknown, variables: Record<string, unknown>) => ClientCache;

@@ -1,10 +0,7 @@

import * as graphql from 'graphql';
import { DocumentNode } from '@0no-co/graphql.web';
import { Future, Result, Option } from '@swan-io/boxed';
import { ClientCache } from './cache/cache.js';
import { ClientError } from './errors.js';
import { TypedDocumentNode } from './types.js';
import '@swan-io/request';
type RequestConfig = {
import { DocumentNode } from "@0no-co/graphql.web";
import { Future, Option, Result } from "@swan-io/boxed";
import { ClientCache } from "./cache/cache";
import { ClientError } from "./errors";
import { TypedDocumentNode } from "./types";
export type RequestConfig = {
url: string;

@@ -16,4 +13,4 @@ headers: Record<string, string>;

};
type MakeRequest = (config: RequestConfig) => Future<Result<unknown, ClientError>>;
type ClientConfig = {
export type MakeRequest = (config: RequestConfig) => Future<Result<unknown, ClientError>>;
export type ClientConfig = {
url: string;

@@ -26,3 +23,3 @@ headers?: Record<string, string>;

};
declare class Client {
export declare class Client {
url: string;

@@ -36,4 +33,4 @@ headers: Record<string, string>;

constructor(config: ClientConfig);
getTransformedDocument(document: DocumentNode): graphql.DocumentNode;
getTransformedDocumentsForRequest(document: DocumentNode): graphql.DocumentNode;
getTransformedDocument(document: DocumentNode): import("graphql").DocumentNode;
getTransformedDocumentsForRequest(document: DocumentNode): import("graphql").DocumentNode;
subscribe(func: () => void): () => boolean;

@@ -45,3 +42,2 @@ request<Data, Variables>(document: TypedDocumentNode<Data, Variables>, variables: Variables, { optimize }?: RequestOptions): Future<Result<Data, ClientError>>;

}
export { Client, type ClientConfig, type MakeRequest, type RequestConfig };
export {};

@@ -1,15 +0,12 @@

import { GraphQLError } from '@0no-co/graphql.web';
import { NetworkError, TimeoutError, BadStatusError, EmptyResponseError } from '@swan-io/request';
declare class InvalidGraphQLResponseError extends Error {
import { GraphQLError } from "@0no-co/graphql.web";
import { BadStatusError, EmptyResponseError, NetworkError, TimeoutError } from "@swan-io/request";
export type ClientError = NetworkError | TimeoutError | BadStatusError | EmptyResponseError | InvalidGraphQLResponseError | GraphQLError[];
export declare class InvalidGraphQLResponseError extends Error {
response: unknown;
constructor(response: unknown);
}
declare const parseGraphQLError: (error: unknown) => GraphQLError;
type ClientError = NetworkError | TimeoutError | BadStatusError | EmptyResponseError | InvalidGraphQLResponseError | GraphQLError[];
declare const ClientError: {
export declare const parseGraphQLError: (error: unknown) => GraphQLError;
export declare const ClientError: {
toArray: (clientError: ClientError) => (GraphQLError | NetworkError | TimeoutError | BadStatusError | EmptyResponseError | InvalidGraphQLResponseError)[];
forEach: (clientError: ClientError, func: (error: NetworkError | TimeoutError | BadStatusError | EmptyResponseError | InvalidGraphQLResponseError | GraphQLError, index?: number) => void) => void;
};
export { ClientError, InvalidGraphQLResponseError, parseGraphQLError };

@@ -1,4 +0,3 @@

import { FieldNode, OperationDefinitionNode, DocumentNode, SelectionSetNode } from '@0no-co/graphql.web';
import { Option } from '@swan-io/boxed';
import { DocumentNode, FieldNode, OperationDefinitionNode, SelectionSetNode } from "@0no-co/graphql.web";
import { Option } from "@swan-io/boxed";
/**

@@ -14,3 +13,3 @@ * Returns a Set<string> with all keys selected within the direct selection sets

*/
declare const getSelectedKeys: (fieldNode: FieldNode | OperationDefinitionNode, variables: Record<string, unknown>) => Set<symbol>;
export declare const getSelectedKeys: (fieldNode: FieldNode | OperationDefinitionNode, variables: Record<string, unknown>) => Set<symbol>;
/**

@@ -32,3 +31,3 @@ * Serializes the field name and arguments as a symbol.

*/
declare const getFieldNameWithArguments: (fieldNode: FieldNode, variables: Record<string, unknown>) => symbol;
export declare const getFieldNameWithArguments: (fieldNode: FieldNode, variables: Record<string, unknown>) => symbol;
/**

@@ -41,3 +40,3 @@ * Returns a record representation of the arguments passed to a given field

*/
declare const extractArguments: (fieldNode: FieldNode, variables: Record<string, unknown>) => Record<string, unknown>;
export declare const extractArguments: (fieldNode: FieldNode, variables: Record<string, unknown>) => Record<string, unknown>;
/**

@@ -49,3 +48,3 @@ * Gets the field name in the response payload from its AST definition

*/
declare const getFieldName: (fieldNode: FieldNode) => string;
export declare const getFieldName: (fieldNode: FieldNode) => string;
/**

@@ -57,3 +56,3 @@ * Simplifies the query for internal processing by inlining all fragments.

*/
declare const inlineFragments: (documentNode: DocumentNode) => DocumentNode;
export declare const inlineFragments: (documentNode: DocumentNode) => DocumentNode;
/**

@@ -65,6 +64,4 @@ * Adds `__typename` to all selection sets in the document

*/
declare const addTypenames: (documentNode: DocumentNode) => DocumentNode;
declare const getExecutableOperationName: (document: DocumentNode) => Option<string>;
declare const addIdIfPreviousSelected: (oldSelectionSet: SelectionSetNode, newSelectionSet: SelectionSetNode) => SelectionSetNode;
export { addIdIfPreviousSelected, addTypenames, extractArguments, getExecutableOperationName, getFieldName, getFieldNameWithArguments, getSelectedKeys, inlineFragments };
export declare const addTypenames: (documentNode: DocumentNode) => DocumentNode;
export declare const getExecutableOperationName: (document: DocumentNode) => Option<string>;
export declare const addIdIfPreviousSelected: (oldSelectionSet: SelectionSetNode, newSelectionSet: SelectionSetNode) => SelectionSetNode;

@@ -1,7 +0,4 @@

import { ASTNode } from '@0no-co/graphql.web';
declare const printString: (string: string) => string;
declare const printBlockString: (string: string) => string;
declare const print: (node: ASTNode) => string;
export { print, printBlockString, printString };
import { ASTNode } from "@0no-co/graphql.web";
export declare const printString: (string: string) => string;
export declare const printBlockString: (string: string) => string;
export declare const print: (node: ASTNode) => string;

@@ -1,15 +0,8 @@

export { Client, ClientConfig, MakeRequest, RequestConfig } from './client.js';
export { ClientError, InvalidGraphQLResponseError, parseGraphQLError } from './errors.js';
export { print } from './graphql/print.js';
export { ClientContext } from './react/ClientContext.js';
export { DeferredQuery, DeferredQueryConfig, useDeferredQuery } from './react/useDeferredQuery.js';
export { Mutation, useMutation } from './react/useMutation.js';
export { useBackwardPagination, useForwardPagination } from './react/usePagination.js';
export { Query, QueryConfig, useQuery } from './react/useQuery.js';
import 'graphql';
import '@0no-co/graphql.web';
import '@swan-io/boxed';
import './cache/cache.js';
import './types.js';
import '@swan-io/request';
import 'react';
export * from "./client";
export * from "./errors";
export { print } from "./graphql/print";
export * from "./react/ClientContext";
export * from "./react/useDeferredQuery";
export * from "./react/useMutation";
export * from "./react/usePagination";
export * from "./react/useQuery";

@@ -9,8 +9,3 @@ 'use strict';

var __defProp = Object.defineProperty;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __publicField = (obj, key, value) => {
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
return value;
};
// src/client.ts

@@ -89,3 +84,3 @@ // src/utils.ts

{ __typename: tsPattern.P.select("name", tsPattern.P.string), id: tsPattern.P.select("id", tsPattern.P.string) },
({ name, id }) => boxed.Option.Some(Symbol.for("".concat(name, "<").concat(id, ">")))
({ name, id }) => boxed.Option.Some(Symbol.for(`${name}<${id}>`))
).otherwise(() => boxed.Option.None());

@@ -107,4 +102,4 @@ };

constructor() {
__publicField(this, "cache", /* @__PURE__ */ new Map());
__publicField(this, "operationCache", /* @__PURE__ */ new Map());
this.cache = /* @__PURE__ */ new Map();
this.operationCache = /* @__PURE__ */ new Map();
}

@@ -247,3 +242,3 @@ dump() {

}
return Symbol.for("".concat(fieldName, "(").concat(JSON.stringify(args), ")"));
return Symbol.for(`${fieldName}(${JSON.stringify(args)})`);
};

@@ -300,3 +295,3 @@ var extractArguments = (fieldNode, variables) => {

if (!fragmentNode) {
throw new Error('Fragment "'.concat(fragmentName, '" is not defined.'));
throw new Error(`Fragment "${fragmentName}" is not defined.`);
}

@@ -413,10 +408,16 @@ const nextNode = {

}
const cacheHasKey = hasOwnProperty.call(
data3,
fieldNameWithArguments
);
const cacheHasKey = hasOwnProperty.call(data3, originalFieldName) || hasOwnProperty.call(data3, fieldNameWithArguments);
if (!cacheHasKey) {
return boxed.Option.None();
}
const valueOrKeyFromCache = data3[fieldNameWithArguments];
const valueOrKeyFromCache = (
// @ts-expect-error `data` is indexable at this point
originalFieldName in data3 ? (
// @ts-expect-error `data` is indexable at this point
data3[originalFieldName]
) : (
// @ts-expect-error `data` is indexable at this point
data3[fieldNameWithArguments]
)
);
if (valueOrKeyFromCache == void 0) {

@@ -776,12 +777,11 @@ return boxed.Option.Some({

};
exports.InvalidGraphQLResponseError = class _InvalidGraphQLResponseError extends Error {
var InvalidGraphQLResponseError = class _InvalidGraphQLResponseError extends Error {
constructor(response) {
super("Received an invalid GraphQL response");
__publicField(this, "response");
this.name = this.constructor.name;
Object.setPrototypeOf(this, _InvalidGraphQLResponseError.prototype);
this.name = "InvalidGraphQLResponseError";
this.response = response;
Object.setPrototypeOf(this, _InvalidGraphQLResponseError.prototype);
}
};
exports.parseGraphQLError = (error) => {
var parseGraphQLError = (error) => {
return tsPattern.match(error).with(

@@ -811,3 +811,3 @@ {

};
exports.ClientError = {
var ClientError = {
toArray: (clientError) => {

@@ -817,3 +817,3 @@ return Array.isArray(clientError) ? clientError : [clientError];

forEach: (clientError, func) => {
exports.ClientError.toArray(clientError).forEach(func);
ClientError.toArray(clientError).forEach(func);
}

@@ -849,5 +849,5 @@ };

VariableDefinition(node) {
let out = nodes.Variable(node.variable) + ": " + exports.print(node.type);
let out = nodes.Variable(node.variable) + ": " + print(node.type);
if (node.defaultValue)
out += " = " + exports.print(node.defaultValue);
out += " = " + print(node.defaultValue);
if (hasItems(node.directives))

@@ -893,3 +893,3 @@ out += " " + node.directives.map(nodes.Directive).join(" ");

ListValue(node) {
return "[" + node.values.map(exports.print).join(", ") + "]";
return "[" + node.values.map(print).join(", ") + "]";
},

@@ -900,12 +900,12 @@ ObjectValue(node) {

ObjectField(node) {
return node.name.value + ": " + exports.print(node.value);
return node.name.value + ": " + print(node.value);
},
Document(node) {
return hasItems(node.definitions) ? node.definitions.map(exports.print).join(" ") : "";
return hasItems(node.definitions) ? node.definitions.map(print).join(" ") : "";
},
SelectionSet(node) {
return "{" + node.selections.map(exports.print).join(" ") + "}";
return "{" + node.selections.map(print).join(" ") + "}";
},
Argument(node) {
return node.name.value + ": " + exports.print(node.value);
return node.name.value + ": " + print(node.value);
},

@@ -924,3 +924,3 @@ FragmentSpread(node) {

out += " " + node.directives.map(nodes.Directive).join(" ");
return out + " " + exports.print(node.selectionSet);
return out + " " + print(node.selectionSet);
},

@@ -932,3 +932,3 @@ FragmentDefinition(node) {

out += " " + node.directives.map(nodes.Directive).join(" ");
return out + " " + exports.print(node.selectionSet);
return out + " " + print(node.selectionSet);
},

@@ -945,9 +945,9 @@ Directive(node) {

ListType(node) {
return "[" + exports.print(node.type) + "]";
return "[" + print(node.type) + "]";
},
NonNullType(node) {
return exports.print(node.type) + "!";
return print(node.type) + "!";
}
};
exports.print = (node) => {
var print = (node) => {
return typeof nodes[node.kind] == "function" ? nodes[node.kind](node) : "";

@@ -971,3 +971,3 @@ };

operationName,
query: exports.print(document),
query: print(document),
variables

@@ -978,17 +978,10 @@ })

{ errors: tsPattern.P.select(tsPattern.P.array()) },
(errors) => boxed.Result.Error(errors.map(exports.parseGraphQLError))
(errors) => boxed.Result.Error(errors.map(parseGraphQLError))
).with({ data: tsPattern.P.select(tsPattern.P.nonNullable) }, (data) => boxed.Result.Ok(data)).otherwise(
(response) => boxed.Result.Error(new exports.InvalidGraphQLResponseError(response))
(response) => boxed.Result.Error(new InvalidGraphQLResponseError(response))
)
);
};
exports.Client = class Client {
var Client = class {
constructor(config) {
__publicField(this, "url");
__publicField(this, "headers");
__publicField(this, "cache");
__publicField(this, "makeRequest");
__publicField(this, "subscribers");
__publicField(this, "transformedDocuments");
__publicField(this, "transformedDocumentsForRequest");
var _a, _b;

@@ -1091,5 +1084,5 @@ this.url = config.url;

};
exports.ClientContext = react.createContext(new exports.Client({ url: "/graphql" }));
exports.useDeferredQuery = (query, { optimize = false } = {}) => {
const client = react.useContext(exports.ClientContext);
var ClientContext = react.createContext(new Client({ url: "/graphql" }));
var useDeferredQuery = (query, { optimize = false, debounce } = {}) => {
const client = react.useContext(ClientContext);
const [stableQuery] = react.useState(query);

@@ -1099,2 +1092,3 @@ const [stableVariables, setStableVariables] = react.useState(

);
const timeoutRef = react.useRef(void 0);
const getSnapshot = react.useCallback(() => {

@@ -1112,3 +1106,2 @@ return stableVariables.flatMap(

}, [data]);
const [isQuerying, setIsQuerying] = react.useState(false);
const runQuery = react.useCallback(

@@ -1122,12 +1115,38 @@ (variables) => {

);
setIsQuerying(true);
return client.request(stableQuery, variables, { optimize }).tap(() => setIsQuerying(false));
},
[client, stableQuery, optimize]
[client, optimize, stableQuery]
);
const [isQuerying, setIsQuerying] = react.useState(false);
const exposedRunQuery = react.useCallback(
(variables) => {
if (timeoutRef.current !== void 0) {
clearTimeout(timeoutRef.current);
}
setIsQuerying(true);
if (debounce === void 0) {
return runQuery(variables);
} else {
const [future, resolve] = boxed.Deferred.make();
timeoutRef.current = window.setTimeout(
(variables2) => {
runQuery(variables2).tap(resolve);
},
debounce,
variables
);
return future;
}
},
[runQuery, debounce]
);
const reset = react.useCallback(() => {
setIsQuerying(false);
setStableVariables(boxed.Option.None());
}, []);
const asyncDataToExpose = isQuerying ? boxed.AsyncData.Loading() : asyncData;
return [asyncDataToExpose, runQuery];
return [asyncDataToExpose, { query: exposedRunQuery, reset }];
};
exports.useMutation = (mutation) => {
const client = react.useContext(exports.ClientContext);
var useMutation = (mutation) => {
const client = react.useContext(ClientContext);
const [stableMutation] = react.useState(mutation);

@@ -1197,4 +1216,4 @@ const [data, setData] = react.useState(

};
exports.useForwardPagination = createPaginationHook("after");
exports.useBackwardPagination = createPaginationHook("before");
var useForwardPagination = createPaginationHook("after");
var useBackwardPagination = createPaginationHook("before");
var usePreviousValue = (value) => {

@@ -1207,13 +1226,15 @@ const previousRef = react.useRef(value);

};
exports.useQuery = (query, variables, { suspense = false, optimize = false } = {}) => {
const client = react.useContext(exports.ClientContext);
var useQuery = (query, variables, { suspense = false, optimize = false } = {}) => {
const client = react.useContext(ClientContext);
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)) {
setIsReloading(true);
setStableVariables([variables, variables]);
}
}, [stableVariables, variables]);
const getSnapshot = react.useCallback(() => {
return client.readFromCache(stableQuery, stableVariables);
return client.readFromCache(stableQuery, stableVariables[1]);
}, [client, stableQuery, stableVariables]);

@@ -1234,3 +1255,3 @@ const data = react.useSyncExternalStore(

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

@@ -1241,3 +1262,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]);

@@ -1247,12 +1268,36 @@ 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]);
const isLoading = isRefreshing || isReloading || asyncData.isLoading();
const asyncDataToExpose = isReloading ? boxed.AsyncData.Loading() : isLoading ? previousAsyncData : asyncData;
if (suspense && asyncDataToExpose.isLoading()) {
throw client.query(stableQuery, stableVariables, { optimize }).toPromise();
if (suspense && isSuspenseFirstFetch.current && asyncDataToExpose.isLoading()) {
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 }];
};
exports.Client = Client;
exports.ClientContext = ClientContext;
exports.ClientError = ClientError;
exports.InvalidGraphQLResponseError = InvalidGraphQLResponseError;
exports.parseGraphQLError = parseGraphQLError;
exports.print = print;
exports.useBackwardPagination = useBackwardPagination;
exports.useDeferredQuery = useDeferredQuery;
exports.useForwardPagination = useForwardPagination;
exports.useMutation = useMutation;
exports.useQuery = useQuery;
//# sourceMappingURL=out.js.map
//# sourceMappingURL=index.js.map

@@ -1,13 +0,3 @@

import * as react from 'react';
import { Client } from '../client.js';
import 'graphql';
import '@0no-co/graphql.web';
import '@swan-io/boxed';
import '../cache/cache.js';
import '../errors.js';
import '@swan-io/request';
import '../types.js';
declare const ClientContext: react.Context<Client>;
export { ClientContext };
/// <reference types="react" />
import { Client } from "../client";
export declare const ClientContext: import("react").Context<Client>;

@@ -1,16 +0,15 @@

import { AsyncData, Result, Future } from '@swan-io/boxed';
import { ClientError } from '../errors.js';
import { TypedDocumentNode } from '../types.js';
import '@0no-co/graphql.web';
import '@swan-io/request';
type DeferredQueryConfig = {
import { AsyncData, Future, Result } from "@swan-io/boxed";
import { ClientError } from "../errors";
import { TypedDocumentNode } from "../types";
export type DeferredQueryConfig = {
optimize?: boolean;
debounce?: number;
};
type DeferredQuery<Data, Variables> = readonly [
export type DeferredQuery<Data, Variables> = readonly [
AsyncData<Result<Data, ClientError>>,
(variables: Variables) => Future<Result<Data, ClientError>>
{
query: (variables: Variables) => Future<Result<Data, ClientError>>;
reset: () => void;
}
];
declare const useDeferredQuery: <Data, Variables>(query: TypedDocumentNode<Data, Variables>, { optimize }?: DeferredQueryConfig) => DeferredQuery<Data, Variables>;
export { type DeferredQuery, type DeferredQueryConfig, useDeferredQuery };
export declare const useDeferredQuery: <Data, Variables>(query: TypedDocumentNode<Data, Variables>, { optimize, debounce }?: DeferredQueryConfig) => DeferredQuery<Data, Variables>;

@@ -1,13 +0,8 @@

import { Future, Result, AsyncData } from '@swan-io/boxed';
import { ClientError } from '../errors.js';
import { TypedDocumentNode } from '../types.js';
import '@0no-co/graphql.web';
import '@swan-io/request';
type Mutation<Data, Variables> = readonly [
import { AsyncData, Future, Result } from "@swan-io/boxed";
import { ClientError } from "../errors";
import { TypedDocumentNode } from "../types";
export type Mutation<Data, Variables> = readonly [
(variables: Variables) => Future<Result<Data, ClientError>>,
AsyncData<Result<Data, ClientError>>
];
declare const useMutation: <Data, Variables>(mutation: TypedDocumentNode<Data, Variables>) => Mutation<Data, Variables>;
export { type Mutation, useMutation };
export declare const useMutation: <Data, Variables>(mutation: TypedDocumentNode<Data, Variables>) => Mutation<Data, Variables>;

@@ -1,6 +0,6 @@

type Edge<T> = {
export type Edge<T> = {
cursor?: string | null;
node?: T | null | undefined;
};
type Connection<T> = {
export type Connection<T> = {
edges?: (Edge<T> | null | undefined)[] | null | undefined;

@@ -14,5 +14,3 @@ pageInfo: {

} | null | undefined;
declare const useForwardPagination: <A, T extends Connection<A>>(connection: T) => T;
declare const useBackwardPagination: <A, T extends Connection<A>>(connection: T) => T;
export { useBackwardPagination, useForwardPagination };
export declare const useForwardPagination: <A, T extends Connection<A>>(connection: T) => T;
export declare const useBackwardPagination: <A, T extends Connection<A>>(connection: T) => T;

@@ -1,12 +0,9 @@

import { AsyncData, Result, Future } from '@swan-io/boxed';
import { ClientError } from '../errors.js';
import { TypedDocumentNode } from '../types.js';
import '@0no-co/graphql.web';
import '@swan-io/request';
type QueryConfig = {
import { AsyncData, Future, Result } from "@swan-io/boxed";
import { ClientError } from "../errors";
import { TypedDocumentNode } from "../types";
export type QueryConfig = {
suspense?: boolean;
optimize?: boolean;
};
type Query<Data> = readonly [
export type Query<Data, Variables> = readonly [
AsyncData<Result<Data, ClientError>>,

@@ -17,6 +14,5 @@ {

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>;
export { type Query, type QueryConfig, useQuery };
export declare const useQuery: <Data, Variables>(query: TypedDocumentNode<Data, Variables>, variables: Variables, { suspense, optimize }?: QueryConfig) => Query<Data, Variables>;

@@ -1,4 +0,3 @@

import { DocumentNode } from '@0no-co/graphql.web';
interface DocumentTypeDecoration<TResult, TVariables> {
import { DocumentNode } from "@0no-co/graphql.web";
export interface DocumentTypeDecoration<TResult, TVariables> {
/**

@@ -11,3 +10,3 @@ * This type is used to ensure that the variables you pass in to the query are assignable to Variables

}
interface TypedDocumentNode<TResult = {
export interface TypedDocumentNode<TResult = {
[key: string]: any;

@@ -18,3 +17,1 @@ }, TVariables = {

}
export type { DocumentTypeDecoration, TypedDocumentNode };

@@ -1,9 +0,7 @@

declare const DEEP_MERGE_DELETE: unique symbol;
declare const deepMerge: (target: any, source: any) => any;
declare const containsAll: <T>(a: Set<T>, b: Set<T>) => boolean;
declare const isRecord: (value: unknown) => value is Record<PropertyKey, unknown>;
declare const hasOwnProperty: (v: PropertyKey) => boolean;
declare const deepEqual: (a: any, b: any) => boolean;
declare const serializeVariables: (variables: Record<string, unknown>) => string;
export { DEEP_MERGE_DELETE, containsAll, deepEqual, deepMerge, hasOwnProperty, isRecord, serializeVariables };
export declare const DEEP_MERGE_DELETE: unique symbol;
export declare const deepMerge: (target: any, source: any) => any;
export declare const containsAll: <T>(a: Set<T>, b: Set<T>) => boolean;
export declare const isRecord: (value: unknown) => value is Record<PropertyKey, unknown>;
export declare const hasOwnProperty: (v: PropertyKey) => boolean;
export declare const deepEqual: (a: any, b: any) => boolean;
export declare const serializeVariables: (variables: Record<string, unknown>) => string;
{
"name": "@swan-io/graphql-client",
"version": "0.1.0-alpha9",
"version": "0.1.0-beta1",
"license": "MIT",

@@ -38,3 +38,3 @@ "description": "A simple, typesafe GraphQL client for React",

"typecheck": "tsc --noEmit",
"build": "tsup",
"build": "tsup && tsc -p tsconfig.build.json --emitDeclarationOnly",
"prepack": "yarn typecheck && yarn test && yarn build",

@@ -51,3 +51,3 @@ "codegen": "graphql-codegen --config codegen.ts"

"@swan-io/boxed": "^2.1.1",
"@swan-io/request": "^1.0.2",
"@swan-io/request": "^1.0.4",
"ts-pattern": "^5.1.0"

@@ -54,0 +54,0 @@ },

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