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-beta5 to 0.1.0-beta6

bin/generate-schema-config

3

dist/cache/cache.d.ts

@@ -9,2 +9,5 @@ import { DocumentNode, OperationDefinitionNode } from "@0no-co/graphql.web";

operationCache: Map<import("graphql").DocumentNode, Map<string, Option<Result<unknown, unknown>>>>;
schemaConfig: Record<string, Set<string>>;
constructor(schemaConfig: Record<string, string[]>);
isTypeCompatible(typename: string, typeCondition: string): boolean;
dump(): Map<symbol, unknown>;

@@ -11,0 +14,0 @@ getOperationFromCache(documentNode: DocumentNode, variables: Record<string, unknown>): Option<Result<unknown, unknown>>;

@@ -19,2 +19,3 @@ import { DocumentNode } from "@0no-co/graphql.web";

makeRequest?: MakeRequest;
schemaConfig: Record<string, string[]>;
};

@@ -21,0 +22,0 @@ type ConnectionUpdate<Node> = [

@@ -97,6 +97,19 @@ 'use strict';

var ClientCache = class {
constructor() {
constructor(schemaConfig) {
this.cache = /* @__PURE__ */ new Map();
this.operationCache = /* @__PURE__ */ new Map();
this.schemaConfig = Object.fromEntries(
Object.entries(schemaConfig).map(([key, value]) => [key, new Set(value)])
);
}
isTypeCompatible(typename, typeCondition) {
if (typename === typeCondition) {
return true;
}
const compatibleTypes = this.schemaConfig[typeCondition];
if (compatibleTypes == void 0) {
return false;
}
return compatibleTypes.has(typename);
}
dump() {

@@ -597,6 +610,6 @@ return this.cache;

{ __typename: tsPattern.P.array({ __typename: tsPattern.P.select(tsPattern.P.string) }) },
(name) => name
(name) => name[0]
).otherwise(() => void 0);
if (typeCondition != null && dataTypename != null) {
if (dataTypename === typeCondition) {
if (cache.isTypeCompatible(dataTypename, typeCondition)) {
return traverse(

@@ -618,3 +631,10 @@ inlineFragmentNode.selectionSet,

const typeCondition2 = (_a2 = selection2.typeCondition) == null ? void 0 : _a2.name.value;
return typeCondition2 === dataTypename;
if (typeCondition2 == null) {
return true;
} else {
return cache.isTypeCompatible(
dataTypename,
typeCondition2
);
}
}

@@ -1126,3 +1146,3 @@ return true;

this.headers = (_a = config.headers) != null ? _a : { "Content-Type": "application/json" };
this.cache = new ClientCache();
this.cache = new ClientCache(config.schemaConfig);
this.makeRequest = (_b = config.makeRequest) != null ? _b : defaultMakeRequest;

@@ -1239,3 +1259,5 @@ this.subscribers = /* @__PURE__ */ new Set();

};
var ClientContext = react.createContext(new Client({ url: "/graphql" }));
var ClientContext = react.createContext(
new Client({ url: "/graphql", schemaConfig: {} })
);
var useDeferredQuery = (query, { optimize = false, debounce } = {}) => {

@@ -1242,0 +1264,0 @@ const client = react.useContext(ClientContext);

{
"name": "@swan-io/graphql-client",
"version": "0.1.0-beta5",
"version": "0.1.0-beta6",
"license": "MIT",

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

},
"bin": {
"generate-schema-config": "bin/generate-schema-config"
},
"files": [
"bin",
"LICENSE",

@@ -30,0 +34,0 @@ "dist",

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