This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
admin-panel/graphql-types/node_modules/@graphql-tools/code-file-loader/index.cjs.js.map

1 line
19 KiB
Plaintext
Raw Normal View History

2021-03-09 18:44:13 +00:00
{"version":3,"file":"index.cjs.js","sources":["../../../dist/loaders/code-file/src/helpers.js","../../../dist/loaders/code-file/src/exports.js","../../../dist/loaders/code-file/src/load-from-module.js","../../../dist/loaders/code-file/src/index.js"],"sourcesContent":["/**\n * @internal\n */\nexport function pick(obj, keys) {\n for (const key of keys) {\n if (obj[key]) {\n return obj[key];\n }\n }\n return obj;\n}\n// checkers\n/**\n * @internal\n */\nexport function isSchemaText(obj) {\n return typeof obj === 'string';\n}\n/**\n * @internal\n */\nexport function isWrappedSchemaJson(obj) {\n const json = obj;\n return json.data !== undefined && json.data.__schema !== undefined;\n}\n/**\n * @internal\n */\nexport function isSchemaJson(obj) {\n const json = obj;\n return json !== undefined && json.__schema !== undefined;\n}\n/**\n * @internal\n */\nexport function isSchemaAst(obj) {\n return obj.kind !== undefined;\n}\n//# sourceMappingURL=helpers.js.map","import { parse, buildClientSchema, isSchema } from 'graphql';\nimport { isSchemaAst, isSchemaJson, isSchemaText, isWrappedSchemaJson, pick } from './helpers';\nconst identifiersToLookFor = ['default', 'schema', 'typeDefs', 'data'];\n// Pick exports\n/**\n * @internal\n */\nexport function pickExportFromModule({ module, filepath }) {\n ensureModule({ module, filepath });\n return resolveModule(ensureExports({ module, filepath }));\n}\n/**\n * @internal\n */\nexport function pickExportFromModuleSync({ module, filepath }) {\n ensureModule({ module, filepath });\n return resolveModuleSync(ensureExports({ module, filepath }));\n}\n// module\nasync function resolveModule(identifiers) {\n const exportValue = await pick(await identifiers, identifiersToLookFor);\n return resolveExport(exportValue);\n}\nfunction resolveModuleSync(identifiers) {\n const exportValue = pick(identifiers, identifiersToLookFor);\n return resolveExport(exportValue);\n}\n// validate\nfunction ensureModule({ module, filepath }) {\n if (!module) {\n throw new Error(`Invalid export from export file ${filepath}: empty export!`);\n }\n}\nfunction ensureExports({ module, filepath }) {\n const identifiers = pick(module, identifiersToLookFor);\n if (!identifiers) {\n throw new Error(`Invalid export from export file ${filepath}: missing default export or 'schema' export!`);\n }\n return identifiers;\n}\n// Decide what to do with an exported value\nfunction resolveExport(fileExport) {\n try {\n if (isSchema(fileExport)) {\n return fileExport;\n }\n if (isSchemaText(fileExport)) {\n return parse(fileExport);\n }\n if (isWrappedSchemaJson(fileExport)) {\n return buildClientSchema(fileExport.data);\n }\n if (isSchemaJson(fileExport)) {\n return buildClientSchema(fileExport);\n }\n if (isSchemaAst(fileExport)) {\n return fileExport;\n }\n return null;\n }\n catch (e) {\n throw new Error('Exported schema must be of type GraphQLSchema, text, AST, or introspection JSON.');\n }\n}\n//# sourceMappingURL=exports.js.map","import { pickExportFromModule, pickExportFromModuleSync } from './exports';\n/**\n * @internal\n */\nexport async function tryToLoadFromExport(rawFilePath) {\n try {\n const filepath = ensureFilepath(rawFilePath);\n const mod = await import(filepath);\n return await pickExportFromModule({ module: mod, filepath });\n }\n catch (e) {\n throw new Error(`Unable to load from file \"${rawFilePath}\": ${e.message}`);\n }\n}\n/**\n * @internal\n */\nexport function tryToLoadFromExportSync(rawFilePath) {\n try {\n const filepath = ensureFilepath(rawFilePath);\n const mod = require(filepath);\n return pickExportFromModuleSync({ module: mod, filepath });\n }\n catch (e) {\n throw new Error(`Unable to load from file \"${rawFilePath}\": ${e.message}`);\n }\n}\n/**\n * @internal\n */\nfunc