The SendGrid Native Data Connector allows for connecting to the SendGrid v3 API and exposing its functionality from your Hasura API. While this is a functional implementation of the SendGrid API, it also serves as a minimal example of an "Action" style connector using the Rust Data Connector SDK.
In order to use this connector you will need to:
- Create a SendGrid API account
- Create an API key
- A Hasura DDN project (see the Getting Started guide)
This connector is a minimal implementation of the SendGrid v3 API functions:
- Sending mail (the
send_mail
procedure) - Getting a list of email templates (the
list_templates
function)
It also serves as an example of how an Action
style connector can be implemented in Hasura V3.
Add the SendGrid connector to your DDN project by running
> ddn connector init -i
Select the SendGrid connector from the list and provide a name for the connector and your SendGrid API key.
Then you need to introspect the connector to get its schema:
> ddn connector introspect <connector name>
And then you can add all the SendGrid commands to your supergraph:
> ddn command add <connector name> "*"
You can now build your supergraph, run it locally, and open the Hasura Console to try it out:
> ddn supergraph build local
> ddn run docker-start
> ddn console --local
The following instructions are for developers who wish to contribute to the SendGrid Connector.
Prerequisites:
- Install rustup.
Commands:
cargo build
SENDGRID_API_KEY="YOUR-API-KEY-HERE" cargo run -- serve --configuration .
docker build . --tag ndc-sendgrid
docker run --rm -it -e SENDGRID_API_KEY="YOUR-API-KEY-HERE" -p 8080:8080 ndc-sendgrid