UNPKG

adminjs-graphql

Version:
38 lines 1.16 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.GraphQLClient = void 0; const axios_1 = __importDefault(require("axios")); const http_1 = require("http"); const https_1 = require("https"); /** * A minimal GraphQL client. */ class GraphQLClient { constructor(endpoint, agentOptions = {}) { const httpAgent = new http_1.Agent(agentOptions); const httpsAgent = new https_1.Agent(agentOptions); this.axios = axios_1.default.create({ baseURL: endpoint, headers: { "content-type": "application/graphql+json", }, httpAgent, httpsAgent, }); } async request(query, variables, headers) { const body = { query, variables }; const response = await this.axios.post("/", body, { headers }); return response.data; } } exports.GraphQLClient = GraphQLClient; //# sourceMappingURL=GraphQLClient.js.map