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/schema/index.esm.js.map

1 line
72 KiB
Plaintext
Raw Normal View History

2021-03-09 18:44:13 +00:00
{"version":3,"file":"index.esm.js","sources":["../../../dist/schema/src/addSchemaLevelResolver.js","../../../dist/schema/src/assertResolversPresent.js","../../../dist/schema/src/attachDirectiveResolvers.js","../../../dist/schema/src/extensionDefinitions.js","../../../dist/schema/src/concatenateTypeDefs.js","../../../dist/schema/src/buildSchemaFromTypeDefinitions.js","../../../dist/schema/src/chainResolvers.js","../../../dist/schema/src/decorateWithLogger.js","../../../dist/schema/src/checkForResolveTypeResolver.js","../../../dist/schema/src/extendResolversFromInterfaces.js","../../../dist/schema/src/addResolversToSchema.js","../../../dist/schema/src/addErrorLoggingToSchema.js","../../../dist/schema/src/addCatchUndefinedToSchema.js","../../../dist/schema/src/makeExecutableSchema.js"],"sourcesContent":["import { defaultFieldResolver } from 'graphql';\nimport { mapSchema, MapperKind } from '@graphql-tools/utils';\n// wraps all resolvers of query, mutation or subscription fields\n// with the provided function to simulate a root schema level resolver\nexport function addSchemaLevelResolver(schema, fn) {\n // TODO test that schema is a schema, fn is a function\n const fnToRunOnlyOnce = runAtMostOncePerRequest(fn);\n return mapSchema(schema, {\n [MapperKind.ROOT_FIELD]: (fieldConfig, _fieldName, typeName, schema) => {\n // XXX this should run at most once per request to simulate a true root resolver\n // for graphql-js this is an approximation that works with queries but not mutations\n // XXX if the type is a subscription, a same query AST will be ran multiple times so we\n // deactivate here the runOnce if it's a subscription. This may not be optimal though...\n const subscription = schema.getSubscriptionType();\n if (subscription != null && subscription.name === typeName) {\n return {\n ...fieldConfig,\n resolve: wrapResolver(fieldConfig.resolve, fn),\n };\n }\n return {\n ...fieldConfig,\n resolve: wrapResolver(fieldConfig.resolve, fnToRunOnlyOnce),\n };\n },\n });\n}\n// XXX badly named function. this doesn't really wrap, it just chains resolvers...\nfunction wrapResolver(innerResolver, outerResolver) {\n return (obj, args, ctx, info) => resolveMaybePromise(outerResolver(obj, args, ctx, info), root => {\n if (innerResolver != null) {\n return innerResolver(root, args, ctx, info);\n }\n return defaultFieldResolver(root, args, ctx, info);\n });\n}\nfunction isPromise(maybePromise) {\n return maybePromise && typeof maybePromise.then === 'function';\n}\n// resolvers can be synchronous or asynchronous. if all resolvers\n// in an operation return synchronously, the execution should return\n// synchronously. the maybe-sync/maybe-async nature of resolvers should be\n// preserved\nfunction resolveMaybePromise(maybePromise, fulfillmentCallback) {\n if (isPromise(maybePromise)) {\n return maybePromise.then(fulfillmentCallback);\n }\n return fulfillmentCallback(maybePromise);\n}\n// XXX this function only works for resolvers\n// XXX very hacky way to remember if the function\n// already ran for this request. This will only work\n// if people don't actually cache the operation.\n// if they do cache the operation, they will have to\n// manually remove the __runAtMostOnce before every request.\nfunction runAtMostOncePerRequest(fn) {\n let value;\n const randomNumber = Math.random();\n return (root, args, ctx, info) => {\n if (!info.operation['__runAtMostOnce']) {\n info.operation['__runAtMostOnce'] = {};\n }\n if (!info.operation['__runAtMostOnce'][randomNumber]) {\n info.operation['__runAtMostOnce'][randomNumber] = true;\n value = fn(root, args, ctx, info);\n }\n return value;\n };\n}\n//# sourceMappingURL=addSchemaLevelResolver.js.map","import { getNamedType, isScalarType } from 'g