npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@amplifiers/amplify-graphql-send-email-transformer

v1.3.5

Published

Amplify GraphQL @sendEmail transformer.

Downloads

19

Readme

amplify-graphql-send-email-transformer

Description

This AWS Amplify directive allows you to send emails from your GraphQL API. It uses AWS SES service to send emails. Once a database INSERT, MODIFY, REMOVE operation is performed, the template is populated with data from the mutation and email is sent out to the recipient.

@sendEmail

Definition

directive @sendEmail(template:Template, trigger:String="INSERT") on OBJECT
  input Template {
    subject: String!
    bodyText: String!
    bodyHtml: String!
    sender: String!
    recipient: String!
  }

Installation

npm install --save @amplifiers/amplify-graphql-send-email-transformer

Import

/amplify/backend/api/<API_NAME>/transform.conf.json

{
  "transformers": [
    "@amplifiers/amplify-graphql-send-email-transformer"
  ]
}

Usage

Append the @sendEmail directive to a model in your GraphQL schema. The @sendEmail directive takes a trigger string and template input object as arguments.

trigger field specifies the BD event type and can be one of the following values: INSERT, MODIFY, REMOVE

subject contains the subject of the email.

bodyHtml contains the HTML body of the email.

bodyText contains the text body of the email.

The sender is the email you have configured with SES to send out the emails.

The recipient is the email address of the recipient.

You can use the {{}} syntax to populate your fields with data from the database event.

Example:

type User
  @model
  @sendEmail(
    trigger: "INSERT"
    template: {
      subject: "Welcome to Amplify"
      bodyHtml: "<body><h1 style='color:#ff00ff'>Hello, {{name}}! Welcome to Amplify!</h1></body>"
      bodyText: "Hello, {{name}}! Welcome to Amplify!\nMessage here"
      sender: "[email protected]",
      recipient: "{{email}}"
    }
  ) {
  id: ID!
  name: String!
  email: String!
}

Setup AWS SES

If it is your first time using SES you will be in a sandbox where you have multiple restrictions and only allowed to send from and to whitelisted email addresses. You can whitelist your own email address by following the instructions:

  1. Go to SES Service in AWS Console and Click “Email Addresses” under Identity Management. Remember the AWS Region where you are registering the email.
  2. Click on “Verify a new email address” and add the email address to which emails will be sent. Remember email addresses are case sensitive.
  3. The above action will send a verification mail from AWS to the added email address to confirm Id and accept emails. Once the user of that email address verifies, you can check “Verification Status” turns to “verified”.
  4. You can “Send a Test Email” to verify the same and check the stats of sent emails in the SES console.

alt text

Development and Contributions

Contributions are more than welcome! Please feel free to open an issue or a pull request. Developer docs are here

License

MIT License