Odoo GraphQL Subscription using Node, Express JS for Sample
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 line
17 KiB

4 months ago
{"version":3,"file":"persisted-queries.cjs","sources":["index.js"],"sourcesContent":["import { __assign } from \"tslib\";\nimport { invariant } from \"../../utilities/globals/index.js\";\nimport { print } from \"../../utilities/index.js\";\nimport { ApolloLink } from \"../core/index.js\";\nimport { Observable, compact, isNonEmptyArray } from \"../../utilities/index.js\";\nimport { cacheSizes, AutoCleanedWeakCache, } from \"../../utilities/index.js\";\nexport var VERSION = 1;\nfunction processErrors(graphQLErrors) {\n var byMessage = Object.create(null), byCode = Object.create(null);\n if (isNonEmptyArray(graphQLErrors)) {\n graphQLErrors.forEach(function (error) {\n var _a;\n byMessage[error.message] = error;\n if (typeof ((_a = error.extensions) === null || _a === void 0 ? void 0 : _a.code) == \"string\")\n byCode[error.extensions.code] = error;\n });\n }\n return {\n persistedQueryNotSupported: !!(byMessage.PersistedQueryNotSupported ||\n byCode.PERSISTED_QUERY_NOT_SUPPORTED),\n persistedQueryNotFound: !!(byMessage.PersistedQueryNotFound || byCode.PERSISTED_QUERY_NOT_FOUND),\n };\n}\nvar defaultOptions = {\n disable: function (_a) {\n var meta = _a.meta;\n return meta.persistedQueryNotSupported;\n },\n retry: function (_a) {\n var meta = _a.meta;\n return meta.persistedQueryNotSupported || meta.persistedQueryNotFound;\n },\n useGETForHashedQueries: false,\n};\nfunction operationDefinesMutation(operation) {\n return operation.query.definitions.some(function (d) { return d.kind === \"OperationDefinition\" && d.operation === \"mutation\"; });\n}\nexport var createPersistedQueryLink = function (options) {\n var hashesByQuery;\n function resetHashCache() {\n hashesByQuery = undefined;\n }\n // Ensure a SHA-256 hash function is provided, if a custom hash\n // generation function is not provided. We don't supply a SHA-256 hash\n // function by default, to avoid forcing one as a dependency. Developers\n // should pick the most appropriate SHA-256 function (sync or async) for\n // their needs/environment, or provide a fully custom hash generation\n // function (via the `generateHash` option) if they want to handle\n // hashing with something other than SHA-256.\n invariant(options &&\n (typeof options.sha256 === \"function\" ||\n typeof options.generateHash === \"function\"), 40);\n var _a = compact(defaultOptions, options), sha256 = _a.sha256, \n // If both a `sha256` and `generateHash` option are provided, the\n // `sha256` option will be ignored. Developers can configure and\n // use any hashing approach they want in a custom `generateHash`\n // function; they aren't limited to SHA-256.\n _b = _a.generateHash, \n // If both a `sha256` and `generateHash` option are provided, the\n // `sha256` option will be ignored. Developers can configure and\n // use any hashing approach they want in a custom `generateHash`\n // function; they aren't limited to SHA-256.\n generateHash = _b === void 0 ? function (query) {\n return Promise.resolve(sha256(print(query)));\n } : _b, disable = _a.disable, retry = _a.retry, useGETForHashedQueries = _a.useGETForHashedQueries;\n var supportsPersistedQueries = true;\n var getHashPromise = function (query) {\n return new Promise(function (resolve) { return resolve(generateHash(query)); });\n };\n function getQueryHash(query) {\n if (!query || typeof query !== \"object\") {\n // If the query is not an object, we won't be able to store its hash as\n // a property of query[hashesKey], so we let generateHash(query) decide\n // what to do with the bogus query.\n return getHashPromise(query);\n }\n if (!hashesByQuery) {\n hashesByQuery = new AutoCleanedWeakCache(cacheSizes[\"PersistedQueryLink.persistedQueryHashes\"] ||\n 2000 /* defaultCacheSizes[\"Per