UNPKG

graphql-yoga

Version:

[![GraphQL Conf 2023](/GraphQLConf-2023-Banner.png)](https://graphql.org/conf/)

23 lines (22 loc) 741 B
import { createGraphQLError } from '@graphql-tools/utils'; export function isValidMethodForGraphQL(method) { return method === 'GET' || method === 'POST'; } export function useCheckMethodForGraphQL() { return { onRequestParse({ request }) { if (!isValidMethodForGraphQL(request.method)) { throw createGraphQLError('GraphQL only supports GET and POST requests.', { extensions: { http: { status: 405, headers: { Allow: 'GET, POST', }, }, }, }); } }, }; }