UNPKG

graphql-helix

Version:

A highly evolved GraphQL HTTP Server 🧬

27 lines (26 loc) • 926 B
import { isHttpMethod } from './util/index.mjs'; export const getGraphQLParameters = (request) => { const { body, method, query: queryParams } = request; let operationName; let query; let variables; let extensions; if (isHttpMethod("GET", method)) { operationName = queryParams.operationName; query = queryParams.query; variables = queryParams.variables; extensions = queryParams.extensions; } else if (isHttpMethod("POST", method)) { operationName = body === null || body === void 0 ? void 0 : body.operationName; query = body === null || body === void 0 ? void 0 : body.query; variables = body === null || body === void 0 ? void 0 : body.variables; extensions = body === null || body === void 0 ? void 0 : body.extension; } return { operationName, query, variables, extensions, }; };