UNPKG

@apollo/client

Version:

A fully-featured caching GraphQL client.

35 lines (34 loc) 1.2 kB
import { Kind } from "graphql"; import { cacheSizes } from "../caching/sizes.js"; import { canonicalStringify } from "./canonicalStringify.js"; import { memoize } from "./memoize.js"; /** * @internal * * @deprecated This is an internal API and should not be used directly. This can be removed or changed at any time. */ export const isStreamField = memoize(function isStreamField(field, variables) { return !!field.directives?.some((directive) => { if (directive.name.value !== "stream") { return false; } for (const arg of directive.arguments ?? []) { if (arg.name.value === "if") { switch (arg.value.kind) { case Kind.BOOLEAN: return arg.value.value; case Kind.VARIABLE: return !!variables?.[arg.value.name.value]; } } } return true; }); }, { max: cacheSizes["isStreamField"] || 2000 /* defaultCacheSizes["isStreamField"] */, makeCacheKey: ([selection, variables]) => [ selection, canonicalStringify(variables), ], }); //# sourceMappingURL=isStreamField.js.map