@swan-io/graphql-client
Advanced tools
Comparing version 0.1.0-beta8 to 0.1.0-beta9
@@ -62,1 +62,2 @@ import { DocumentNode, FieldNode, OperationDefinitionNode, SelectionSetNode } from "@0no-co/graphql.web"; | ||
export declare const addIdIfPreviousSelected: (oldSelectionSet: SelectionSetNode, newSelectionSet: SelectionSetNode) => SelectionSetNode; | ||
export declare const isExcluded: (fieldNode: FieldNode, variables: Record<string, unknown>) => boolean; |
@@ -517,2 +517,12 @@ 'use strict'; | ||
}; | ||
var isExcluded = (fieldNode, variables) => { | ||
if (!boxed.Array.isArray(fieldNode.directives)) { | ||
return false; | ||
} | ||
return fieldNode.directives.some( | ||
(directive) => directive.name.value === "include" && directive.arguments != null && directive.arguments.some((arg) => { | ||
return arg.name.value === "if" && extractValue(arg.value, variables) === false; | ||
}) | ||
); | ||
}; | ||
@@ -537,2 +547,3 @@ // src/cache/read.ts | ||
var STABILITY_CACHE = /* @__PURE__ */ new WeakMap(); | ||
var EXCLUDED = Symbol.for("EXCLUDED"); | ||
var readOperationFromCache = (cache, document, variables) => { | ||
@@ -555,3 +566,10 @@ const traverse = (selections, data) => { | ||
if (!cacheHasKey) { | ||
return boxed.Option.None(); | ||
if (isExcluded(fieldNode, variables)) { | ||
return boxed.Option.Some({ | ||
...data3, | ||
[originalFieldName]: EXCLUDED | ||
}); | ||
} else { | ||
return boxed.Option.None(); | ||
} | ||
} | ||
@@ -558,0 +576,0 @@ const valueOrKeyFromCache = ( |
{ | ||
"name": "@swan-io/graphql-client", | ||
"version": "0.1.0-beta8", | ||
"version": "0.1.0-beta9", | ||
"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
346186
3313