Configuring HTTP Allowed Methods on Gateway #6255
-
Hello, I'm trying to configure our GraphQL Mesh Gateway so that the endpoint only accepts Is there a way of configuring a list of allowed HTTP methods that is allowed on our mesh gateway? Many thanks |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
You can write a custom plugin (Mesh uses GraphQL Yoga so you can use GraphQL Yoga hooks -> https://the-guild.dev/graphql/yoga-server/docs/features/envelop-plugins#onrequest); import { MeshPlugin } from '@graphql-mesh/types';
const allowPOSTOnly: MeshPlugin = {
onRequest({ request, fetchAPI, endResponse }) {
if (request.method !== 'POST') {
endResponse(
new fetchAPI.Response(null, { status: 405, statusText: 'Method Not Allowed' })
}
}
}
const plugins = [allowPOSTOnly];
export default plugins]; Then pass it as an additional plugin; https://the-guild.dev/graphql/mesh/docs/plugins/plugins-introduction#additional-plugins additionalEnvelopPlugins: "./custom-plugins" |
Beta Was this translation helpful? Give feedback.
You can write a custom plugin (Mesh uses GraphQL Yoga so you can use GraphQL Yoga hooks -> https://the-guild.dev/graphql/yoga-server/docs/features/envelop-plugins#onrequest);
Then pass it as an additional plugin; https://the-guild.dev/graphql/mesh/docs/plugins/plugins-introduction#additional-plugins
additionalEnvelopPlugins: "./custom-…