GraphQL is a hot new technology for fetching data using a graph. MailSlurp offers a free email address API that you can use to create inboxes, read email, send emails and more. Let's see how it works.

Where is it?

Access the MailSlurp GraphQL email API endpoint at https://graphql.mailslurp.com. If you load the url in a browser you'll see the GraphQL explorer. You can use it to perform queries or use your own graphql client locally.

Install GraphQL client

You can install MailSlurp's graphQL library using NPM:

Note you will need a free MailSlurp API key. Create an API key at MailSlurp account dashboard and store the value safely. Then use the key in code to configure the client. We must create a client that sets an header using your MailSlurp account API KEY.

Making a query

You can make queries like so. Note that the example method call should use backticks to use template string invocation. Note you can use raw strings without gql too if you prefer.

The great thing about graphql is that you can explore the MailSlurp API schema yourself using the provided GraphQL Playground

Mutations

Here is how you can perform mutations.

Send email

And here is a way to send emails using GraphQL.

Further reading

For more information please see the GraphQL email guide.