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ACA,SAAS,UAAU,EAAW,GAE1B,IADyB,QAAQ,GAE7B,MAAM,IAAI,MAAM,EAExB,CApEA,QAAQ,YAAc,YA6CtB,QAAQ,iBAAmB","file":"/npm/express-graphql@0.12.0/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.19.2.\n * Original file: /npm/express-graphql@0.12.0/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","\"use strict\";\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n    return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.getGraphQLParams = exports.graphqlHTTP = void 0;\nconst accepts_1 = __importDefault(require(\"accepts\"));\nconst http_errors_1 = __importDefault(require(\"http-errors\"));\nconst graphql_1 = require(\"graphql\");\nconst parseBody_1 = require(\"./parseBody\");\nconst renderGraphiQL_1 = require(\"./renderGraphiQL\");\n/**\n * Middleware for express; takes an options object or function as input to\n * configure behavior, and returns an express middleware.\n */\nfunction graphqlHTTP(options) {\n    devAssert(options != null, 'GraphQL middleware requires options.');\n    return async function graphqlMiddleware(request, response) {\n        var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;\n        // Higher scoped variables are referred to at various stages in the asynchronous state machine below.\n        let params;\n        let showGraphiQL = false;\n        let graphiqlOptions;\n        let formatErrorFn = graphql_1.formatError;\n        let pretty = false;\n        let result;\n        try {\n            // Parse the Request to get GraphQL request parameters.\n            try {\n                params = await getGraphQLParams(request);\n            }\n            catch (error) {\n                // When we failed to parse the GraphQL parameters, we still need to get\n                // the options object, so make an options call to resolve just that.\n                const optionsData = await resolveOptions();\n                pretty = (_a = optionsData.pretty) !== null && _a !== void 0 ? _a : false;\n                formatErrorFn = (_c = (_b = optionsData.customFormatErrorFn) !== null && _b !== void 0 ? _b : optionsData.formatError) !== null && _c !== void 0 ? _c : formatErrorFn;\n                throw error;\n            }\n            // Then, resolve the Options to get OptionsData.\n            const optionsData = await resolveOptions(params);\n            // Collect information from the options data object.\n            const schema = optionsData.schema;\n            const rootValue = optionsData.rootValue;\n            const validationRules = (_d = optionsData.validationRules) !== null && _d !== void 0 ? _d : [];\n            const fieldResolver = optionsData.fieldResolver;\n            const typeResolver = optionsData.typeResolver;\n            const graphiql = (_e = optionsData.graphiql) !== null && _e !== void 0 ? _e : false;\n            const extensionsFn = optionsData.extensions;\n            const context = (_f = optionsData.context) !== null && _f !== void 0 ? _f : request;\n            const parseFn = (_g = optionsData.customParseFn) !== null && _g !== void 0 ? _g : graphql_1.parse;\n            const executeFn = (_h = optionsData.customExecuteFn) !== null && _h !== void 0 ? _h : graphql_1.execute;\n            const validateFn = (_j = optionsData.customValidateFn) !== null && _j !== void 0 ? _j : graphql_1.validate;\n            pretty = (_k = optionsData.pretty) !== null && _k !== void 0 ? _k : false;\n            formatErrorFn = (_m = (_l = optionsData.customFormatErrorFn) !== null && _l !== void 0 ? _l : optionsData.formatError) !== null && _m !== void 0 ? _m : formatErrorFn;\n            // Assert that schema is required.\n            devAssert(schema != null, 'GraphQL middleware options must contain a schema.');\n            // GraphQL HTTP only supports GET and POST methods.\n            if (request.method !== 'GET' && request.method !== 'POST') {\n                throw http_errors_1.default(405, 'GraphQL only supports GET and POST requests.', {\n                    headers: { Allow: 'GET, POST' },\n                });\n            }\n            // Get GraphQL params from the request and POST body data.\n            const { query, variables, operationName } = params;\n            showGraphiQL = canDisplayGraphiQL(request, params) && graphiql !== false;\n            if (typeof graphiql !== 'boolean') {\n                graphiqlOptions = graphiql;\n            }\n            // If there is no query, but GraphiQL will be displayed, do not produce\n            // a result, otherwise return a 400: Bad Request.\n            if (query == null) {\n                if (showGraphiQL) {\n                    return respondWithGraphiQL(response, graphiqlOptions);\n                }\n                throw http_errors_1.default(400, 'Must provide query string.');\n            }\n            // Validate Schema\n            const schemaValidationErrors = graphql_1.validateSchema(schema);\n            if (schemaValidationErrors.length > 0) {\n                // Return 500: Internal Server Error if invalid schema.\n                throw http_errors_1.default(500, 'GraphQL schema validation error.', {\n                    graphqlErrors: schemaValidationErrors,\n                });\n            }\n            // Parse source to AST, reporting any syntax error.\n            let documentAST;\n            try {\n                documentAST = parseFn(new graphql_1.Source(query, 'GraphQL request'));\n            }\n            catch (syntaxError) {\n                // Return 400: Bad Request if any syntax errors errors exist.\n                throw http_errors_1.default(400, 'GraphQL syntax error.', {\n                    graphqlErrors: [syntaxError],\n                });\n            }\n            // Validate AST, reporting any errors.\n            const validationErrors = validateFn(schema, documentAST, [\n                ...graphql_1.specifiedRules,\n                ...validationRules,\n            ]);\n            if (validationErrors.length > 0) {\n                // Return 400: Bad Request if any validation errors exist.\n                throw http_errors_1.default(400, 'GraphQL validation error.', {\n                    graphqlErrors: validationErrors,\n                });\n            }\n            // Only query operations are allowed on GET requests.\n            if (request.method === 'GET') {\n                // Determine if this GET request will perform a non-query.\n                const operationAST = graphql_1.getOperationAST(documentAST, operationName);\n                if (operationAST && operationAST.operation !== 'query') {\n                    // If GraphiQL can be shown, do not perform this query, but\n                    // provide it to GraphiQL so that the requester may perform it\n                    // themselves if desired.\n                    if (showGraphiQL) {\n                        return respondWithGraphiQL(response, graphiqlOptions, params);\n                    }\n                    // Otherwise, report a 405: Method Not Allowed error.\n                    throw http_errors_1.default(405, `Can only perform a ${operationAST.operation} operation from a POST request.`, { headers: { Allow: 'POST' } });\n                }\n            }\n            // Perform the execution, reporting any errors creating the context.\n            try {\n                result = await executeFn({\n                    schema,\n                    document: documentAST,\n                    rootValue,\n                    contextValue: context,\n                    variableValues: variables,\n                    operationName,\n                    fieldResolver,\n                    typeResolver,\n                });\n            }\n            catch (contextError) {\n                // Return 400: Bad Request if any execution context errors exist.\n                throw http_errors_1.default(400, 'GraphQL execution context error.', {\n                    graphqlErrors: [contextError],\n                });\n            }\n            // Collect and apply any metadata extensions if a function was provided.\n            // https://graphql.github.io/graphql-spec/#sec-Response-Format\n            if (extensionsFn) {\n                const extensions = await extensionsFn({\n                    document: documentAST,\n                    variables,\n                    operationName,\n                    result,\n                    context,\n                });\n                if (extensions != null) {\n                    result = { ...result, extensions };\n                }\n            }\n        }\n        catch (rawError) {\n            // If an error was caught, report the httpError status, or 500.\n            const error = http_errors_1.default(500, \n            /* istanbul ignore next: Thrown by underlying library. */\n            rawError instanceof Error ? rawError : String(rawError));\n            response.statusCode = error.status;\n            const { headers } = error;\n            if (headers != null) {\n                for (const [key, value] of Object.entries(headers)) {\n                    response.setHeader(key, String(value));\n                }\n            }\n            if (error.graphqlErrors == null) {\n                const graphqlError = new graphql_1.GraphQLError(error.message, undefined, undefined, undefined, undefined, error);\n                result = { data: undefined, errors: [graphqlError] };\n            }\n            else {\n                result = { data: undefined, errors: error.graphqlErrors };\n            }\n        }\n        // If no data was included in the result, that indicates a runtime query\n        // error, indicate as such with a generic status code.\n        // Note: Information about the error itself will still be contained in\n        // the resulting JSON payload.\n        // https://graphql.github.io/graphql-spec/#sec-Data\n        if (response.statusCode === 200 && result.data == null) {\n            response.statusCode = 500;\n        }\n        // Format any encountered errors.\n        const formattedResult = {\n            ...result,\n            errors: (_o = result.errors) === null || _o === void 0 ? void 0 : _o.map(formatErrorFn),\n        };\n        // If allowed to show GraphiQL, present it instead of JSON.\n        if (showGraphiQL) {\n            return respondWithGraphiQL(response, graphiqlOptions, params, formattedResult);\n        }\n        // If \"pretty\" JSON isn't requested, and the server provides a\n        // response.json method (express), use that directly.\n        // Otherwise use the simplified sendResponse method.\n        if (!pretty && typeof response.json === 'function') {\n            response.json(formattedResult);\n        }\n        else {\n            const payload = JSON.stringify(formattedResult, null, pretty ? 2 : 0);\n            sendResponse(response, 'application/json', payload);\n        }\n        async function resolveOptions(requestParams) {\n            const optionsResult = await Promise.resolve(typeof options === 'function'\n                ? options(request, response, requestParams)\n                : options);\n            devAssert(optionsResult != null && typeof optionsResult === 'object', 'GraphQL middleware option function must return an options object or a promise which will be resolved to an options object.');\n            if (optionsResult.formatError) {\n                // eslint-disable-next-line no-console\n                console.warn('`formatError` is deprecated and replaced by `customFormatErrorFn`. It will be removed in version 1.0.0.');\n            }\n            return optionsResult;\n        }\n    };\n}\nexports.graphqlHTTP = graphqlHTTP;\nfunction respondWithGraphiQL(response, options, params, result) {\n    const data = {\n        query: params === null || params === void 0 ? void 0 : params.query,\n        variables: params === null || params === void 0 ? void 0 : params.variables,\n        operationName: params === null || params === void 0 ? void 0 : params.operationName,\n        result,\n    };\n    const payload = renderGraphiQL_1.renderGraphiQL(data, options);\n    return sendResponse(response, 'text/html', payload);\n}\n/**\n * Provided a \"Request\" provided by express or connect (typically a node style\n * HTTPClientRequest), Promise the GraphQL request parameters.\n */\nasync function getGraphQLParams(request) {\n    var _a, _b, _c;\n    const urlData = new URLSearchParams(request.url.split('?')[1]);\n    const bodyData = await parseBody_1.parseBody(request);\n    // GraphQL Query string.\n    let query = (_a = urlData.get('query')) !== null && _a !== void 0 ? _a : bodyData.query;\n    if (typeof query !== 'string') {\n        query = null;\n    }\n    // Parse the variables if needed.\n    let variables = ((_b = urlData.get('variables')) !== null && _b !== void 0 ? _b : bodyData.variables);\n    if (typeof variables === 'string') {\n        try {\n            variables = JSON.parse(variables);\n        }\n        catch (_d) {\n            throw http_errors_1.default(400, 'Variables are invalid JSON.');\n        }\n    }\n    else if (typeof variables !== 'object') {\n        variables = null;\n    }\n    // Name of GraphQL operation to execute.\n    let operationName = (_c = urlData.get('operationName')) !== null && _c !== void 0 ? _c : bodyData.operationName;\n    if (typeof operationName !== 'string') {\n        operationName = null;\n    }\n    const raw = urlData.get('raw') != null || bodyData.raw !== undefined;\n    return { query, variables, operationName, raw };\n}\nexports.getGraphQLParams = getGraphQLParams;\n/**\n * Helper function to determine if GraphiQL can be displayed.\n */\nfunction canDisplayGraphiQL(request, params) {\n    // If `raw` false, GraphiQL mode is not enabled.\n    // Allowed to show GraphiQL if not requested as raw and this request prefers HTML over JSON.\n    return !params.raw && accepts_1.default(request).types(['json', 'html']) === 'html';\n}\n/**\n * Helper function for sending a response using only the core Node server APIs.\n */\nfunction sendResponse(response, type, data) {\n    const chunk = Buffer.from(data, 'utf8');\n    response.setHeader('Content-Type', type + '; charset=utf-8');\n    response.setHeader('Content-Length', String(chunk.length));\n    response.end(chunk);\n}\nfunction devAssert(condition, message) {\n    const booleanCondition = Boolean(condition);\n    if (!booleanCondition) {\n        throw new Error(message);\n    }\n}\n"]}