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

gqty

Package Overview
Dependencies
Maintainers
0
Versions
318
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gqty - npm Package Compare versions

Comparing version 3.3.0-canary-20240813061317.7895a8e2b4c0b3c14eb3459cd6bc528a82cfd86c to 3.3.0-canary-20240907140915.1abad53615bbcfa64e489cc31f581e65c71342b2

Client/alias.d.ts

2

Accessor/index.js

@@ -30,3 +30,3 @@ 'use strict';

return;
const selection = (_a = selectionCache.get(key)) != null ? _a : Selection.Selection.createRoot(key, { aliasLength: context.aliasLength });
const selection = (_a = selectionCache.get(key)) != null ? _a : Selection.Selection.createRoot(key);
selectionCache.set(key, selection);

@@ -33,0 +33,0 @@ return resolve.createObjectAccessor({

@@ -177,10 +177,28 @@ 'use strict';

if (__args) {
return (args) => resolve(
proxy,
meta$1.selection.getChild(
key,
args ? { input: { types: __args, values: args } } : {}
),
__type
);
return (args) => {
var _a, _b;
const alias = (_b = (_a = meta$1.context).aliasGenerator) == null ? void 0 : _b.call(
_a,
meta$1.selection.ancestry.map((s) => s.key.toString()).concat(key),
args
);
const input = {};
if (args) {
for (const key2 in args) {
input[key2] = {
alias: alias == null ? void 0 : alias.input[key2],
type: __args[key2],
value: args[key2]
};
}
}
return resolve(
proxy,
meta$1.selection.getChild(
key,
args ? { alias: alias == null ? void 0 : alias.field, input } : {}
),
__type
);
};
}

@@ -317,3 +335,3 @@ return resolve(proxy, meta$1.selection.getChild(key), __type);

if ((parent == null ? void 0 : parent.key) !== "$on") {
accessor.__typename;
Reflect.get(accessor, "__typename");
}

@@ -324,3 +342,3 @@ const keys = getIdentityFields(meta$1);

if (isUnion && ((_a = parent == null ? void 0 : parent.parent) == null ? void 0 : _a.children.has(key))) continue;
accessor[key];
Reflect.get(accessor, key);
}

@@ -347,3 +365,3 @@ };

}
if (key === "length") proxy[0];
if (key === "length") Reflect.get(proxy, 0);
const numKey = +key;

@@ -350,0 +368,0 @@ if (!isNaN(numKey) && numKey < data.length) {

@@ -7,3 +7,2 @@ 'use strict';

const index = require('../../Error/index.js');
require('../../Utils/hash.js');
const meta = require('../../Accessor/meta.js');

@@ -10,0 +9,0 @@ require('../../Accessor/resolve.js');

@@ -5,3 +5,2 @@ 'use strict';

require('../../Utils/hash.js');
const meta = require('../../Accessor/meta.js');

@@ -8,0 +7,0 @@ require('../../Accessor/resolve.js');

@@ -81,3 +81,11 @@ 'use strict';

const convertSelection = (selection, selectionId = 0, operationName) => {
var _a, _b;
const args = {};
const argTypes = {};
if (selection.input) {
for (const key in selection.input) {
const { type, value } = selection.input[key];
args[key] = value;
argTypes[key] = type;
}
}
return new LegacySelection({

@@ -88,4 +96,4 @@ id: ++selectionId,

prevSelection: selection.parent ? convertSelection(selection.parent, selectionId, operationName) : void 0,
args: (_a = selection.input) == null ? void 0 : _a.values,
argTypes: (_b = selection.input) == null ? void 0 : _b.types,
args,
argTypes,
type: selection.root.key === "query" ? 0 /* Query */ : selection.root.key === "mutation" ? 1 /* Mutation */ : 2 /* Subscription */,

@@ -92,0 +100,0 @@ operationName,

@@ -6,5 +6,6 @@ import { Cache, type CacheGetOptions } from '../Cache';

import type { Selectable } from '../Selectable';
import type { AliasGenerator } from './alias';
export type SchemaContext<T extends Record<string, unknown> = Record<string, unknown>> = T & Disposable & Resetable & Selectable & {
cache: Cache;
readonly aliasLength?: number;
readonly aliasGenerator?: AliasGenerator;
readonly cacheOptions?: CacheGetOptions;

@@ -23,3 +24,3 @@ readonly depthLimit: number;

export type CreateContextOptions = {
aliasLength?: number;
aliasGenerator?: AliasGenerator;
cache: Cache;

@@ -32,2 +33,2 @@ depthLimit: number;

};
export declare const createContext: ({ aliasLength, cache, cachePolicy, depthLimit, scalars, schema, typeKeys, }: CreateContextOptions) => SchemaContext;
export declare const createContext: ({ aliasGenerator, cache, cachePolicy, depthLimit, scalars, schema, typeKeys, }: CreateContextOptions) => SchemaContext;

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

const createContext = ({
aliasLength,
aliasGenerator,
cache,

@@ -20,3 +20,3 @@ cachePolicy,

return {
aliasLength,
aliasGenerator,
cache: cachePolicy === "no-cache" || cachePolicy === "no-store" || cachePolicy === "reload" ? new index.Cache(void 0, { maxAge: 0 }) : cache,

@@ -23,0 +23,0 @@ cacheOptions: {

@@ -7,8 +7,7 @@ import type { Client as SseClient } from 'graphql-sse';

import type { GeneratedSchemaObject, QueryFetcher, ScalarsEnumsHash, Schema } from '../Schema';
import { type AliasGenerator } from './alias';
import { type LegacyClient, type LegacyClientOptions } from './compat/client';
import { type Debugger } from './debugger';
import { type Resolvers } from './resolvers';
export { $meta } from '../Accessor';
export { getFields, prepass, selectFields } from '../Helpers';
export * as useMetaStateHack from '../Helpers/useMetaStateHack';
export * from './alias';
export type { LegacyClientOptions as LegacyFetchers, LegacyHydrateCache, LegacyHydrateCacheOptions, LegacyInlineResolved, LegacyInlineResolveOptions, LegacyMutate, LegacyMutateHelpers, LegacyPrefetch, LegacyQueryFetcher, LegacyRefetch, LegacyResolved, LegacyResolveOptions, LegacySelection, LegacySubscribeEvents, LegacySubscriptionsClient, LegacyTrack, LegacyTrackCallInfo, LegacyTrackCallType, LegacyTrackOptions, } from './compat/client';

@@ -67,5 +66,12 @@ export type { SchemaContext } from './context';

* @default 6
* @deprecated Use `aliasGenerator` instead.
*/
aliasLength?: number;
/**
* Alias generator function, useful for debugging and logging.
*
* This option takes precedence over `aliasLength`.
*/
aliasGenerator?: AliasGenerator;
/**
* Milliseconds to wait before pending queries are batched up for fetching.

@@ -103,2 +109,2 @@ */

};
export declare const createClient: <TSchema extends BaseGeneratedSchema, _ObjectTypesNames extends string = never, _ObjectTypes extends SchemaObjects<TSchema> = never>({ aliasLength, batchWindow, cache, fetchOptions: { fetcher, cachePolicy: fetchPolicy, retryPolicy: defaultRetryPolicy, subscriber, ...fetchOptions }, scalars, schema, __depthLimit, ...legacyOptions }: ClientOptions & LegacyClientOptions) => Client<TSchema>;
export declare const createClient: <TSchema extends BaseGeneratedSchema, _ObjectTypesNames extends string = never, _ObjectTypes extends SchemaObjects<TSchema> = never>({ aliasLength, aliasGenerator, batchWindow, cache, fetchOptions: { fetcher, cachePolicy: fetchPolicy, retryPolicy: defaultRetryPolicy, subscriber, ...fetchOptions }, scalars, schema, __depthLimit, ...legacyOptions }: ClientOptions & LegacyClientOptions) => Client<TSchema>;

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

const persistence = require('../Cache/persistence.js');
const alias = require('./alias.js');
const client = require('./compat/client.js');

@@ -15,12 +16,7 @@ const queryFetcher = require('./compat/queryFetcher.js');

const resolvers = require('./resolvers.js');
require('flatted');
const getFields = require('../Helpers/getFields.js');
const prepass = require('../Helpers/prepass.js');
const selectFields = require('../Helpers/selectFields.js');
const useMetaStateHack = require('../Helpers/useMetaStateHack.js');
const resolveSelections = require('./resolveSelections.js');
const meta = require('../Accessor/meta.js');
const createClient = ({
aliasLength = 6,
aliasGenerator = alias.createAliasHasher(aliasLength),
batchWindow,

@@ -62,3 +58,3 @@ // This default cache on a required option is for legacy clients, which does

const clientContext = context.createContext({
aliasLength,
aliasGenerator,
cache,

@@ -72,3 +68,3 @@ depthLimit: __depthLimit,

const resolvers$1 = resolvers.createResolvers({
aliasLength,
aliasGenerator,
batchWindow,

@@ -118,9 +114,6 @@ scalars,

exports.getFields = getFields.getFields;
exports.prepass = prepass.prepass;
exports.selectFields = selectFields.selectFields;
exports.useMetaStateHack = useMetaStateHack;
exports.createAliasHasher = alias.createAliasHasher;
exports.createDebugAliasHasher = alias.createDebugAliasHasher;
exports.fetchSelections = resolveSelections.fetchSelections;
exports.subscribeSelections = resolveSelections.subscribeSelections;
exports.$meta = meta.$meta;
exports.createClient = createClient;

@@ -6,2 +6,3 @@ import type { BaseGeneratedSchema, FetchOptions } from '.';

import type { Selection } from '../Selection';
import type { AliasGenerator } from './alias';
import { type SchemaContext } from './context';

@@ -11,3 +12,3 @@ import type { Debugger } from './debugger';

export type CreateResolversOptions = {
aliasLength?: number;
aliasGenerator: AliasGenerator;
batchWindow?: number;

@@ -153,2 +154,2 @@ cache: Cache;

};
export declare const createResolvers: <TSchema extends BaseGeneratedSchema>({ aliasLength, batchWindow, cache: resolverCache, debugger: debug, depthLimit, fetchOptions, fetchOptions: { cachePolicy: defaultCachePolicy, retryPolicy: defaultRetryPoliy, }, scalars, schema, parentContext, }: CreateResolversOptions) => Resolvers<TSchema>;
export declare const createResolvers: <TSchema extends BaseGeneratedSchema>({ aliasGenerator, batchWindow, cache: resolverCache, debugger: debug, depthLimit, fetchOptions, fetchOptions: { cachePolicy: defaultCachePolicy, retryPolicy: defaultRetryPoliy, }, scalars, schema, parentContext, }: CreateResolversOptions) => Resolvers<TSchema>;

@@ -29,3 +29,3 @@ 'use strict';

const createResolvers = ({
aliasLength,
aliasGenerator,
batchWindow,

@@ -62,3 +62,3 @@ cache: resolverCache,

const context$1 = context.createContext({
aliasLength,
aliasGenerator,
cache: resolverCache,

@@ -87,2 +87,3 @@ cachePolicy,

const { accessor } = index.createSchemaAccessor(context$1);
let activePromise;
const resolve = async () => {

@@ -142,3 +143,3 @@ if (selections.size === 0) {

updateCaches.updateCaches(results, [...targetCaches], {
skipNotify: !context$1.notifyCacheUpdate
skipNotify: promiseDropped() || !context$1.notifyCacheUpdate
});

@@ -160,7 +161,4 @@ correlatedCaches.delete(resolverCache);

const currentPromise = pendingQueries.get(pendingSelections)();
const promiseDropped = () => {
var _a;
const activePromise = (_a = pendingQueries.get(pendingSelections)) == null ? void 0 : _a();
return activePromise && currentPromise !== activePromise;
};
activePromise = currentPromise;
const promiseDropped = () => activePromise !== void 0 && currentPromise !== activePromise;
currentPromise.then(

@@ -178,2 +176,3 @@ () => {

context$1.reset();
activePromise = void 0;
});

@@ -180,0 +179,0 @@ }

@@ -8,2 +8,3 @@ export * from './casters';

export * from './selectFields';
export * as useMetaStateHack from './useMetaStateHack';
export * from './variables';

@@ -12,2 +12,3 @@ 'use strict';

const selectFields = require('./selectFields.js');
const useMetaStateHack = require('./useMetaStateHack.js');

@@ -29,1 +30,2 @@

exports.selectFields = selectFields.selectFields;
exports.useMetaStateHack = useMetaStateHack;

@@ -0,1 +1,2 @@

export { $meta } from './Accessor';
export * from './Cache';

@@ -2,0 +3,0 @@ export * from './Client';

@@ -5,5 +5,8 @@ 'use strict';

const index$2 = require('./Error/index.js');
const Selection = require('./Selection.js');
const meta = require('./Accessor/meta.js');
require('./Accessor/resolve.js');
const index = require('./Cache/index.js');
const index$1 = require('./Client/index.js');
const index$2 = require('./Error/index.js');
const casters = require('./Helpers/casters.js');

@@ -16,7 +19,6 @@ const deepCopy = require('./Helpers/deepCopy.js');

const selectFields = require('./Helpers/selectFields.js');
const useMetaStateHack = require('./Helpers/useMetaStateHack.js');
const Schema = require('./Schema.js');
const Selection = require('./Selection.js');
const meta = require('./Accessor/meta.js');
const resolveSelections = require('./Client/resolveSelections.js');
const useMetaStateHack = require('./Helpers/useMetaStateHack.js');
const alias = require('./Client/alias.js');
const retry = require('./Error/retry.js');

@@ -26,5 +28,7 @@

exports.GQtyError = index$2.GQtyError;
exports.Selection = Selection.Selection;
exports.$meta = meta.$meta;
exports.Cache = index.Cache;
exports.createClient = index$1.createClient;
exports.GQtyError = index$2.GQtyError;
exports.castNotSkeleton = casters.castNotSkeleton;

@@ -43,9 +47,9 @@ exports.castNotSkeletonDeep = casters.castNotSkeletonDeep;

exports.selectFields = selectFields.selectFields;
exports.useMetaStateHack = useMetaStateHack;
exports.SchemaUnionsKey = Schema.SchemaUnionsKey;
exports.parseSchemaType = Schema.parseSchemaType;
exports.Selection = Selection.Selection;
exports.$meta = meta.$meta;
exports.fetchSelections = resolveSelections.fetchSelections;
exports.subscribeSelections = resolveSelections.subscribeSelections;
exports.useMetaStateHack = useMetaStateHack;
exports.createAliasHasher = alias.createAliasHasher;
exports.createDebugAliasHasher = alias.createDebugAliasHasher;
exports.doRetry = retry.doRetry;
{
"name": "gqty",
"version": "3.3.0-canary-20240813061317.7895a8e2b4c0b3c14eb3459cd6bc528a82cfd86c",
"version": "3.3.0-canary-20240907140915.1abad53615bbcfa64e489cc31f581e65c71342b2",
"description": "The No-GraphQL Client for TypeScript",

@@ -23,3 +23,3 @@ "sideEffects": false,

"dependencies": {
"debounce-microtasks": "^0.1.7",
"debounce-microtasks": "^0.1.8",
"flatted": "^3.3.1",

@@ -26,0 +26,0 @@ "frail-map": "^1.0.10",

@@ -51,13 +51,5 @@ 'use strict';

if (!inputDedupe.has(input)) {
const queryInputs = Object.entries(input.values).map(([key2, value]) => {
var _a2;
const variableName = hash.hash(((_a2 = s.alias) != null ? _a2 : s.key) + "_" + key2).slice(
0,
s.aliasLength
);
root.args.set(`${variableName}`, {
value,
type: input.types[key2]
});
return `${key2}:$${variableName}`;
const queryInputs = Object.entries(input).map(([key2, { alias = key2, type: type2, value }]) => {
root.args.set(alias, { value, type: type2 });
return `${key2}:$${alias}`;
}).filter(Boolean).join(" ");

@@ -64,0 +56,0 @@ inputDedupe.set(input, `${key}(${queryInputs})`);

export type SelectionOptions = {
readonly alias?: string;
readonly aliasLength?: number;
readonly input?: SelectionInput;

@@ -8,6 +7,7 @@ readonly isUnion?: boolean;

};
export type SelectionInput = {
readonly types: Record<string, string>;
readonly values: Record<string, unknown>;
};
export type SelectionInput = Record<string, {
alias?: string;
type: string;
value: unknown;
}>;
export type SelectionSnapshot = Array<[

@@ -23,3 +23,2 @@ string | number,

get alias(): string | undefined;
get aliasLength(): number | undefined;
get input(): SelectionInput | undefined;

@@ -26,0 +25,0 @@ /** Indicates current selection being a inteface/union key. */

@@ -6,3 +6,2 @@ 'use strict';

const index = require('./Error/index.js');
const hash = require('./Utils/hash.js');

@@ -13,18 +12,2 @@ var __defProp = Object.defineProperty;

const createSymbol = Symbol();
const aliasGenerator = {
seq: 0,
map: /* @__PURE__ */ new WeakMap(),
hash: hash.hash,
get(key, input) {
var _a;
const hash2 = this.hash({ key, ...input });
if (hash2) return hash2;
const seq = (_a = this.map.get(input)) != null ? _a : this.seq++;
if (seq >= Number.MAX_SAFE_INTEGER) {
throw new index.GQtyError(`selection alias fallback overflow`);
}
this.map.set(input, seq);
return `alias${seq}`;
}
};
class Selection {

@@ -42,6 +25,2 @@ constructor(key, options = {}, token) {

}
get aliasLength() {
var _a, _b, _c;
return (_c = (_b = this.options.aliasLength) != null ? _b : (_a = this.parent) == null ? void 0 : _a.aliasLength) != null ? _c : 6;
}
get input() {

@@ -83,6 +62,5 @@ return this.options.input;

getChild(key, options) {
var _a, _b, _c;
const alias = (_b = options == null ? void 0 : options.alias) != null ? _b : (options == null ? void 0 : options.input) ? aliasGenerator.get(key, options.input).slice(0, (_a = options == null ? void 0 : options.aliasLength) != null ? _a : this.aliasLength) : void 0;
const hashKey = alias != null ? alias : key.toString();
const selection = (_c = this.children.get(hashKey)) != null ? _c : new Selection(key, { ...options, alias, parent: this }, createSymbol);
var _a, _b;
const hashKey = (_a = options == null ? void 0 : options.alias) != null ? _a : key.toString();
const selection = (_b = this.children.get(hashKey)) != null ? _b : new Selection(key, { ...options, parent: this }, createSymbol);
this.children.set(hashKey, selection);

@@ -89,0 +67,0 @@ return selection;

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

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

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

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