MessagesForMacintosh/JS/node_modules/apollo-link-http-common/lib/bundle.cjs.js.map

1 line
9.6 KiB
Plaintext
Raw Normal View History

{"version":3,"file":"bundle.cjs.js","sources":["bundle.esm.js"],"sourcesContent":["import { __assign } from 'tslib';\nimport { print } from 'graphql/language/printer';\nimport { InvariantError } from 'ts-invariant';\n\nvar defaultHttpOptions = {\n includeQuery: true,\n includeExtensions: false,\n};\nvar defaultHeaders = {\n accept: '*/*',\n 'content-type': 'application/json',\n};\nvar defaultOptions = {\n method: 'POST',\n};\nvar fallbackHttpConfig = {\n http: defaultHttpOptions,\n headers: defaultHeaders,\n options: defaultOptions,\n};\nvar throwServerError = function (response, result, message) {\n var error = new Error(message);\n error.name = 'ServerError';\n error.response = response;\n error.statusCode = response.status;\n error.result = result;\n throw error;\n};\nvar parseAndCheckHttpResponse = function (operations) { return function (response) {\n return (response\n .text()\n .then(function (bodyText) {\n try {\n return JSON.parse(bodyText);\n }\n catch (err) {\n var parseError = err;\n parseError.name = 'ServerParseError';\n parseError.response = response;\n parseError.statusCode = response.status;\n parseError.bodyText = bodyText;\n return Promise.reject(parseError);\n }\n })\n .then(function (result) {\n if (response.status >= 300) {\n throwServerError(response, result, \"Response not successful: Received status code \" + response.status);\n }\n if (!Array.isArray(result) &&\n !result.hasOwnProperty('data') &&\n !result.hasOwnProperty('errors')) {\n throwServerError(response, result, \"Server response was missing for query '\" + (Array.isArray(operations)\n ? operations.map(function (op) { return op.operationName; })\n : operations.operationName) + \"'.\");\n }\n return result;\n }));\n}; };\nvar checkFetcher = function (fetcher) {\n if (!fetcher && typeof fetch === 'undefined') {\n var library = 'unfetch';\n if (typeof window === 'undefined')\n library = 'node-fetch';\n throw process.env.NODE_ENV === \"production\" ? new InvariantError(1) : new InvariantError(\"\\nfetch is not found globally and no fetcher passed, to fix pass a fetch for\\nyour environment like https://www.npmjs.com/package/\" + library + \".\\n\\nFor example:\\nimport fetch from '\" + library + \"';\\nimport { createHttpLink } from 'apollo-link-http';\\n\\nconst link = createHttpLink({ uri: '/graphql', fetch: fetch });\");\n }\n};\nvar createSignalIfSupported = function () {\n if (typeof AbortController === 'undefined')\n return { controller: false, signal: false };\n var controller = new AbortController();\n var signal = controller.signal;\n return { controller: controller, signal: signal };\n};\nvar selectHttpOptionsAndBody = function (operation, fallbackConfig) {\n var configs = [];\n for (var _i = 2; _i < arguments.length; _i++) {\n configs[_i - 2] = arguments[_i];\n }\n var options = __assign({}, fallbackConfig.options, { headers: fallbackConfig.headers, credentials: fallbackConfig.credentials });\n var http = fallbackConfig.http;\n configs.forEach(function (config) {\n options = __assign({}, options, config.options, { headers: __assign({}, options.headers, config.headers) });\n if (config.credentials)\n options.credentials = config.credentials;\n http = __assign({}, http, config.http);\n });\n var operationName = operation.operationName, extensions = operation.extensions, variables = operation.variables, query = operation.query;\n var body = { operationName: operationName, variables: variables };\n if (http.includeExtensions)\n body.extensions = extensions;\n if (http.includeQuery)\n body.query = print(query);\n return {\n options: options,\n body: body,\n };\n};\nvar serializeFetchParameter =