Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including graphql-form-handler with all npm packages installed. Try it out:

var graphqlFormHandler = require("graphql-form-handler")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

graphql-form-handler v0.0.4

GraphQL Forms Handler

This package provides a generalized graphql mutation meant to handle key-value pair data submitted through an HTML form. The data is sent to an email target using Mailgun.


$ npm install graphlql-form-handler --save


The GraphQL mutation behavior is baked into the package, however, the email template and Mailgun credentials (Mailgun must be configured) can be configured.

This usage example shows how the package can be used with ExpressJS.

const {GraphQLSchema, GraphQLObjectType} = require('graphql');
const {createGraphQLFormHandlerMutation} = require('graphql-form-handler');
const express = require('express');
const expressGraphQL = require('express-graphql');

const mutationConfig = {
  mailgun: {
    apiKey: 'key-XXXXXXXX',
    domain: '',
    from: '',
    to: '',
    subject: 'Contact Request from Customer',
  template: `
        <p>Here's a form submission!</p>

const schema = new GraphQLSchema({
  query: ...,
  mutation: new GraphQLObjectType({
    name: 'mutation',
    fields: () => ({
      formHandler: createGraphQLFormHandlerMutation(mutationConfig),

const app = express();

app.use('/graphql', expressGraphQL((request) => ({
  rootValue: {request},
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free