Initial Sample.

This commit is contained in:
anand committed 2024-06-03 20:23:50 +05:30
1 parent ef2b65f673
commit 5269ec3c66
2575 files changed
+282312

No files matched your search

@@ -0,0 +1,18 @@
import type { DocumentNode, VariableDefinitionNode } from "graphql";
export declare enum DocumentType {
Query = 0,
Mutation = 1,
Subscription = 2
}
export interface IDocumentDefinition {
type: DocumentType;
name: string;
variables: ReadonlyArray<VariableDefinitionNode>;
}
export declare function operationName(type: DocumentType): string;
export declare function parser(document: DocumentNode): IDocumentDefinition;
export declare namespace parser {
var resetCache: () => void;
}
export declare function verifyDocumentType(document: DocumentNode, type: DocumentType): void;
//# sourceMappingURL=index.d.ts.map
+109
View File
@@ -0,0 +1,109 @@
import { invariant } from "../../utilities/globals/index.js";
import { AutoCleanedWeakCache, cacheSizes, } from "../../utilities/index.js";
import { registerGlobalCache } from "../../utilities/caching/getMemoryInternals.js";
export var DocumentType;
(function (DocumentType) {
DocumentType[DocumentType["Query"] = 0] = "Query";
DocumentType[DocumentType["Mutation"] = 1] = "Mutation";
DocumentType[DocumentType["Subscription"] = 2] = "Subscription";
})(DocumentType || (DocumentType = {}));
var cache;
export function operationName(type) {
var name;
switch (type) {
case DocumentType.Query:
name = "Query";
break;
case DocumentType.Mutation:
name = "Mutation";
break;
case DocumentType.Subscription:
name = "Subscription";
break;
}
return name;
}
// This parser is mostly used to safety check incoming documents.
export function parser(document) {
if (!cache) {
cache = new AutoCleanedWeakCache(cacheSizes.parser || 1000 /* defaultCacheSizes.parser */);
}
var cached = cache.get(document);
if (cached)
return cached;
var variables, type, name;
invariant(!!document && !!document.kind, 59, document);
var fragments = [];
var queries = [];
var mutations = [];
var subscriptions = [];
for (var _i = 0, _a = document.definitions; _i < _a.length; _i++) {
var x = _a[_i];
if (x.kind === "FragmentDefinition") {
fragments.push(x);
continue;
}
if (x.kind === "OperationDefinition") {
switch (x.operation) {
case "query":
queries.push(x);
break;
case "mutation":
mutations.push(x);
break;
case "subscription":
subscriptions.push(x);
break;
}
}
}
invariant(!fragments.length ||
queries.length ||
mutations.length ||
subscriptions.length, 60);
invariant(
queries.length + mutations.length + subscriptions.length <= 1,
61,
document,
queries.length,
subscriptions.length,
mutations.length
);
type = queries.length ? DocumentType.Query : DocumentType.Mutation;
if (!queries.length && !mutations.length)
type = DocumentType.Subscription;
var definitions = queries.length ? queries
: mutations.length ? mutations
: subscriptions;
invariant(definitions.length === 1, 62, document, definitions.length);
var definition = definitions[0];
variables = definition.variableDefinitions || [];
if (definition.name && definition.name.kind === "Name") {
name = definition.name.value;
}
else {
name = "data"; // fallback to using data if no name
}
var payload = { name: name, type: type, variables: variables };
cache.set(document, payload);
return payload;
}
parser.resetCache = function () {
cache = undefined;
};
if (globalThis.__DEV__ !== false) {
registerGlobalCache("parser", function () { return (cache ? cache.size : 0); });
}
export function verifyDocumentType(document, type) {
var operation = parser(document);
var requiredOperationName = operationName(type);
var usedOperationName = operationName(operation.type);
invariant(
operation.type === type,
63,
requiredOperationName,
requiredOperationName,
usedOperationName
);
}
//# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/react/parser/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAQ7D,OAAO,EACL,oBAAoB,EACpB,UAAU,GAEX,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,mBAAmB,EAAE,MAAM,+CAA+C,CAAC;AAEpF,MAAM,CAAN,IAAY,YAIX;AAJD,WAAY,YAAY;IACtB,iDAAK,CAAA;IACL,uDAAQ,CAAA;IACR,+DAAY,CAAA;AACd,CAAC,EAJW,YAAY,KAAZ,YAAY,QAIvB;AAQD,IAAI,KASC,CAAC;AAEN,MAAM,UAAU,aAAa,CAAC,IAAkB;IAC9C,IAAI,IAAI,CAAC;IACT,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,YAAY,CAAC,KAAK;YACrB,IAAI,GAAG,OAAO,CAAC;YACf,MAAM;QACR,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IAEjD,IAAI,UAAU,CAAC,IAAI,IAAI,UAAU,CAAC,IAAI,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;QACvD,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC;IAC/B,CAAC;SAAM,CAAC;QACN,IAAI,GAAG,MAAM,CAAC,CAAC,oCAAoC;IACrD,CAAC;IAED,IAAM,OAAO,GAAG,EAAE,IAAI,MAAA,EAAE,IAAI,MAAA,EAAE,SAAS,WAAA,EAAE,CAAC;IAC1C,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC7B,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,MAAM,CAAC,UAAU,GAAG;IAClB,KAAK,GAAG,SAAS,CAAC;AACpB,CAAC,CAAC;AAEF,IAAI,OAAO,EAAE,CAAC;IACZ,mBAAmB,CAAC,QAAQ,EAAE,cAAM,OAAA,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAxB,CAAwB,CAAC,CAAC;AAChE,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,QAAsB,EAAE,IAAkB;IAC3E,IAAM,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;IACnC,IAAM,qBAAqB,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;IAClD,IAAM,iBAAiB,GAAG,aAAa,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACxD,SAAS,CACP,SAAS,CAAC,IAAI,KAAK,IAAI,EACvB,kCAAkC,GAAG,gCAAgC,EACrE,qBAAqB,EACrB,qBAAqB,EACrB,iBAAiB,CAClB,CAAC;AACJ,CAAC","sourcesContent":["import { invariant } from \"../../utilities/globals/index.js\";\n\nimport type {\n DocumentNode,\n DefinitionNode,\n VariableDefinitionNode,\n OperationDefinitionNode,\n} from \"graphql\";\nimport {\n AutoCleanedWeakCache,\n cacheSizes,\n defaultCacheSizes,\n} from \"../../utilities/index.js\";\nimport { registerGlobalCache } from \"../../utilities/caching/getMemoryInternals.js\";\n\nexport enum DocumentType {\n Query,\n Mutation,\n Subscription,\n}\n\nexport interface IDocumentDefinition {\n type: DocumentType;\n name: string;\n variables: ReadonlyArray<VariableDefinitionNode>;\n}\n\nlet cache:\n | undefined\n | AutoCleanedWeakCache<\n DocumentNode,\n {\n name: string;\n type: DocumentType;\n variables: readonly VariableDefinitionNode[];\n }\n >;\n\nexport function operationName(type: DocumentType) {\n let name;\n switch (type) {\n case DocumentType.Query:\n name = \"Query\";\n break;\n case DocumentType.Mutation:\n name = \"Mutation\";\n break;\n case DocumentType.Subscription:\n name = \"Subscription\";\n break;\n }\n return name;\n}\n\n// This parser is mostly used to safety check incoming documents.\nexport function parser(document: DocumentNode): IDocumentDefinition {\n if (!cache) {\n cache = new AutoCleanedWeakCache(\n cacheSizes.parser || defaultCacheSizes.parser\n );\n }\n const cachedLine truncated
@@ -0,0 +1,8 @@
{
"name": "@apollo/client/react/parser",
"type": "module",
"main": "parser.cjs",
"module": "index.js",
"types": "index.d.ts",
"sideEffects": false
}
@@ -0,0 +1,122 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var globals = require('../../utilities/globals');
var utilities = require('../../utilities');
require('tslib');
var globalCaches = {};
function registerGlobalCache(name, getSize) {
globalCaches[name] = getSize;
}
exports.DocumentType = void 0;
(function (DocumentType) {
DocumentType[DocumentType["Query"] = 0] = "Query";
DocumentType[DocumentType["Mutation"] = 1] = "Mutation";
DocumentType[DocumentType["Subscription"] = 2] = "Subscription";
})(exports.DocumentType || (exports.DocumentType = {}));
var cache;
function operationName(type) {
var name;
switch (type) {
case exports.DocumentType.Query:
name = "Query";
break;
case exports.DocumentType.Mutation:
name = "Mutation";
break;
case exports.DocumentType.Subscription:
name = "Subscription";
break;
}
return name;
}
function parser(document) {
if (!cache) {
cache = new utilities.AutoCleanedWeakCache(utilities.cacheSizes.parser || 1000 );
}
var cached = cache.get(document);
if (cached)
return cached;
var variables, type, name;
globals.invariant(!!document && !!document.kind, 59, document);
var fragments = [];
var queries = [];
var mutations = [];
var subscriptions = [];
for (var _i = 0, _a = document.definitions; _i < _a.length; _i++) {
var x = _a[_i];
if (x.kind === "FragmentDefinition") {
fragments.push(x);
continue;
}
if (x.kind === "OperationDefinition") {
switch (x.operation) {
case "query":
queries.push(x);
break;
case "mutation":
mutations.push(x);
break;
case "subscription":
subscriptions.push(x);
break;
}
}
}
globals.invariant(!fragments.length ||
queries.length ||
mutations.length ||
subscriptions.length, 60);
globals.invariant(
queries.length + mutations.length + subscriptions.length <= 1,
61,
document,
queries.length,
subscriptions.length,
mutations.length
);
type = queries.length ? exports.DocumentType.Query : exports.DocumentType.Mutation;
if (!queries.length && !mutations.length)
type = exports.DocumentType.Subscription;
var definitions = queries.length ? queries
: mutations.length ? mutations
: subscriptions;
globals.invariant(definitions.length === 1, 62, document, definitions.length);
var definition = definitions[0];
variables = definition.variableDefinitions || [];
if (definition.name && definition.name.kind === "Name") {
name = definition.name.value;
}
else {
name = "data";
}
var payload = { name: name, type: type, variables: variables };
cache.set(document, payload);
return payload;
}
parser.resetCache = function () {
cache = undefined;
};
if (globalThis.__DEV__ !== false) {
registerGlobalCache("parser", function () { return (cache ? cache.size : 0); });
}
function verifyDocumentType(document, type) {
var operation = parser(document);
var requiredOperationName = operationName(type);
var usedOperationName = operationName(operation.type);
globals.invariant(
operation.type === type,
63,
requiredOperationName,
requiredOperationName,
usedOperationName
);
}
exports.operationName = operationName;
exports.parser = parser;
exports.verifyDocumentType = verifyDocumentType;
//# sourceMappingURL=parser.cjs.map
@@ -0,0 +1 @@
{"version":3,"file":"parser.cjs","sources":["../../utilities/caching/getMemoryInternals.js","index.js"],"sourcesContent":["import { __assign, __spreadArray } from \"tslib\";\nimport { cacheSizes } from \"./sizes.js\";\nvar globalCaches = {};\nexport function registerGlobalCache(name, getSize) {\n globalCaches[name] = getSize;\n}\n/**\n * For internal purposes only - please call `ApolloClient.getMemoryInternals` instead\n * @internal\n */\nexport var getApolloClientMemoryInternals = globalThis.__DEV__ !== false ?\n _getApolloClientMemoryInternals\n : undefined;\n/**\n * For internal purposes only - please call `ApolloClient.getMemoryInternals` instead\n * @internal\n */\nexport var getInMemoryCacheMemoryInternals = globalThis.__DEV__ !== false ?\n _getInMemoryCacheMemoryInternals\n : undefined;\n/**\n * For internal purposes only - please call `ApolloClient.getMemoryInternals` instead\n * @internal\n */\nexport var getApolloCacheMemoryInternals = globalThis.__DEV__ !== false ?\n _getApolloCacheMemoryInternals\n : undefined;\nfunction getCurrentCacheSizes() {\n // `defaultCacheSizes` is a `const enum` that will be inlined during build, so we have to reconstruct it's shape here\n var defaults = {\n parser: 1000 /* defaultCacheSizes[\"parser\"] */,\n canonicalStringify: 1000 /* defaultCacheSizes[\"canonicalStringify\"] */,\n print: 2000 /* defaultCacheSizes[\"print\"] */,\n \"documentTransform.cache\": 2000 /* defaultCacheSizes[\"documentTransform.cache\"] */,\n \"queryManager.getDocumentInfo\": 2000 /* defaultCacheSizes[\"queryManager.getDocumentInfo\"] */,\n \"PersistedQueryLink.persistedQueryHashes\": 2000 /* defaultCacheSizes[\"PersistedQueryLink.persistedQueryHashes\"] */,\n \"fragmentRegistry.transform\": 2000 /* defaultCacheSizes[\"fragmentRegistry.transform\"] */,\n \"fragmentRegistry.lookup\": 1000 /* defaultCacheSizes[\"fragmentRegistry.lookup\"] */,\n \"fragmentRegistry.findFragmentSpreads\": 4000 /* defaultCacheSizes[\"fragmentRegistry.findFragmentSpreads\"] */,\n \"cache.fragmentQueryDocuments\": 1000 /* defaultCacheSizes[\"cache.fragmentQueryDocuments\"] */,\n \"removeTypenameFromVariables.getVariableDefinitions\": 2000 /* defaultCacheSizes[\"removeTypenameFromVariables.getVariableDefinitions\"] */,\n \"inMemoryCache.maybeBroadcastWatch\": 5000 /* defaultCacheSizes[\"inMemoryCache.maybeBroadcastWatch\"] */,\n \"inMemoryCache.executeSelectionSet\": 50000 /* defaultCacheSizes[\"inMemoryCache.executeSelectionSet\"] */,\n \"inMemoryCache.executeSubSelectedArray\": 10000 /* defaultCacheSizes[\"inMemoryCache.executeSubSelectedArray\"] */,\n };\n return Object.fromEntries(Object.entries(defaults).map(function (_a) {\n var k = _a[0], v = _a[1];\n return [\n k,\n cacheSizes[k] || v,\n ];\n }));\n}\nfunction _getApolloClientMemoryInternals() {\n var _a, _b, _c, _d, _e;\n if (!(globalThis.__DEV__ !== false))\n throw new Error(\"only supported in development mode\");\n return {\n limits: getCurrentCacheSizes(),\n sizes: __assign({ print: (_a = globalCaches.print) === null || _a === void 0 ? void 0 : _a.call(globalCaches), parser: (_b = globalCaches.parser) === null || _b === void 0 ? void 0 : _b.call(globalCaches), canonicalStringify: (_c = globalCaches.canonicalStringify) === null || _c === void 0 ? void 0 : _c.call(globalCaches), links: linkInfo(this.link), queryManager: {\n getDocumentInfo: this[\"queryManager\"][\"transformCache\"].size,\n documentTransforms: transformInfo(this[\"queryManager\"].documentTransform),\n } }, (_e = (_d = this.cache).getMemoryInternals) === null || _e === void 0 ? void 0 : _e.call(_d)),\n };\n}\nfunction _getApolloCacheMemoryInternals() {\n return {\n cache: {\n fragmentQueryDocuments: getWrapperInformation(this[\"getFragmentDoc\"]),\n },\n };\n}\nfunction _getInMemoryCacheMemoryInternals() {\n var fragments = this.config.fragments;\n return __assign(__assign({}, _getApolloCacheMemoryInternals.apply(this)), { addTypenameDocumentTransform: transformInfo(this[\"addTypenameTransform\"]), inMemoryCache: {\n executeSelectionSet: getWrapperInformation(this[\"storeReader\"][\"executeSelectionSet\"]),\n executeSubSelectedArray: getWrapperInformation(this[\"storeReader\"][\"executeSubSelectedArray\"]),\n maybeBroadcastWatch: getWrapperInformation(this[\"maybeBroadcastWatch\"]),\n }, fragmentRegistry: {\n findFragmentSpreads: getWrapperInformation(fragments === null || fragments === void 0 ? void 0 : fragments.findFragmentSpreads),\n lookup: getWrapperInformation(fragments === null || fragments === void 0 ? void 0 : fragments.lookup),\n transform: getWrapperInformation(fragments === null || fragments === void 0 ? void 0 : fragmentsLine truncated
@@ -0,0 +1,122 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var globals = require('../../utilities/globals');
var utilities = require('../../utilities');
require('tslib');
var globalCaches = {};
function registerGlobalCache(name, getSize) {
globalCaches[name] = getSize;
}
exports.DocumentType = void 0;
(function (DocumentType) {
DocumentType[DocumentType["Query"] = 0] = "Query";
DocumentType[DocumentType["Mutation"] = 1] = "Mutation";
DocumentType[DocumentType["Subscription"] = 2] = "Subscription";
})(exports.DocumentType || (exports.DocumentType = {}));
var cache;
function operationName(type) {
var name;
switch (type) {
case exports.DocumentType.Query:
name = "Query";
break;
case exports.DocumentType.Mutation:
name = "Mutation";
break;
case exports.DocumentType.Subscription:
name = "Subscription";
break;
}
return name;
}
function parser(document) {
if (!cache) {
cache = new utilities.AutoCleanedWeakCache(utilities.cacheSizes.parser || 1000 );
}
var cached = cache.get(document);
if (cached)
return cached;
var variables, type, name;
globals.invariant(!!document && !!document.kind, 59, document);
var fragments = [];
var queries = [];
var mutations = [];
var subscriptions = [];
for (var _i = 0, _a = document.definitions; _i < _a.length; _i++) {
var x = _a[_i];
if (x.kind === "FragmentDefinition") {
fragments.push(x);
continue;
}
if (x.kind === "OperationDefinition") {
switch (x.operation) {
case "query":
queries.push(x);
break;
case "mutation":
mutations.push(x);
break;
case "subscription":
subscriptions.push(x);
break;
}
}
}
globals.invariant(!fragments.length ||
queries.length ||
mutations.length ||
subscriptions.length, 60);
globals.invariant(
queries.length + mutations.length + subscriptions.length <= 1,
61,
document,
queries.length,
subscriptions.length,
mutations.length
);
type = queries.length ? exports.DocumentType.Query : exports.DocumentType.Mutation;
if (!queries.length && !mutations.length)
type = exports.DocumentType.Subscription;
var definitions = queries.length ? queries
: mutations.length ? mutations
: subscriptions;
globals.invariant(definitions.length === 1, 62, document, definitions.length);
var definition = definitions[0];
variables = definition.variableDefinitions || [];
if (definition.name && definition.name.kind === "Name") {
name = definition.name.value;
}
else {
name = "data";
}
var payload = { name: name, type: type, variables: variables };
cache.set(document, payload);
return payload;
}
parser.resetCache = function () {
cache = undefined;
};
if (globalThis.__DEV__ !== false) {
registerGlobalCache("parser", function () { return (cache ? cache.size : 0); });
}
function verifyDocumentType(document, type) {
var operation = parser(document);
var requiredOperationName = operationName(type);
var usedOperationName = operationName(operation.type);
globals.invariant(
operation.type === type,
63,
requiredOperationName,
requiredOperationName,
usedOperationName
);
}
exports.operationName = operationName;
exports.parser = parser;
exports.verifyDocumentType = verifyDocumentType;
//# sourceMappingURL=parser.cjs.map