{"version":3,"file":"GraphQLAPI.mjs","sources":["../../src/GraphQLAPI.ts"],"sourcesContent":["import { ApiAction, Category, } from '@aws-amplify/core/internals/utils';\nimport { INTERNAL_USER_AGENT_OVERRIDE, } from '@aws-amplify/data-schema/runtime';\nimport { InternalGraphQLAPIClass } from './internals/InternalGraphQLAPI';\nfunction isGraphQLOptionsWithOverride(options) {\n    return INTERNAL_USER_AGENT_OVERRIDE in options;\n}\nexport const graphqlOperation = (query, variables = {}, authToken) => ({\n    query,\n    variables,\n    authToken,\n});\n/**\n * Export Cloud Logic APIs\n */\nexport class GraphQLAPIClass extends InternalGraphQLAPIClass {\n    getModuleName() {\n        return 'GraphQLAPI';\n    }\n    /**\n     * Executes a GraphQL operation\n     *\n     * @param options - GraphQL Options\n     * @param [additionalHeaders] - headers to merge in after any `libraryConfigHeaders` set in the config\n     * @returns An Observable if the query is a subscription query, else a promise of the graphql result.\n     */\n    graphql(amplify, options, additionalHeaders) {\n        const userAgentDetails = {\n            category: Category.API,\n            action: ApiAction.GraphQl,\n        };\n        if (isGraphQLOptionsWithOverride(options)) {\n            const { [INTERNAL_USER_AGENT_OVERRIDE]: internalUserAgentOverride, ...cleanOptions } = options;\n            return super.graphql(amplify, cleanOptions, additionalHeaders, {\n                ...userAgentDetails,\n                ...internalUserAgentOverride,\n            });\n        }\n        return super.graphql(amplify, options, additionalHeaders, {\n            ...userAgentDetails,\n        });\n    }\n    /**\n     * Checks to see if an error thrown is from an api request cancellation\n     * @param error - Any error\n     * @returns A boolean indicating if the error was from an api request cancellation\n     */\n    isCancelError(error) {\n        return super.isCancelError(error);\n    }\n    /**\n     * Cancels an inflight request. Only applicable for graphql queries and mutations\n     * @param {any} request - request to cancel\n     * @returns A boolean indicating if the request was cancelled\n     */\n    cancel(request, message) {\n        return super.cancel(request, message);\n    }\n}\nexport const GraphQLAPI = new GraphQLAPIClass();\n"],"names":[],"mappings":";;;;AAGA,SAAS,4BAA4B,CAAC,OAAO,EAAE;AAC/C,IAAI,O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