I am trying to add the ses template and send a tes...
# prisma-whats-new
d
I am trying to add the ses template and send a test mutation in a playground and getting an error. Looking for some assistance if possible. Following this guide: https://github.com/graphcool/templates/tree/master/messaging/ses I am getting the following error: “Function returned invalid status code: 0. Raw body: empty.last” when I try to run this mutation:
Copy code
mutation {
  sendSesEmail(
    from: "__FROM_EMAIL__"
    to: "__TO_EMAIL__"
    subject: "A new email from the Graphcool SES template!"
    html: "<b>This is your first email from the Graphcool SES template!</b>"
    text: "This is your first email from the Graphcool SES template!"
  ) {
    success
  }
}
r
Check your
gcf logs
, that usually indicates that the function errored out but didn't return anything useful. You should be able to get more detail from your logs, though.
d
That error is actually the output of
Copy code
graphcool-framework logs -f sendEmail --tail
I’ve been looking for something else to go off of but that seems to be all I can find.
r
Ah, fair enough then
d
Only other thing I can confirm is that if I remove the AWS environment variables I get a different error which is coming directly from sendEmail.ts
Copy code
"2018-01-25T19:52:37.267Z": "Please provide a valid AWS Access Key ID!"
    }
  ],
  "returnValue": {
    "error": "Module not configured correctly."
  }
As soon as I put the keys in, I get the error about Raw.body empty.last
m
how are you pulling in your AWS keys? In Graphcool, AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are protected environment variables. So you can't use them
*that's the framework
@Daniel Carroll
also double check the
to
field is an array of strings. I had this error when I was passing a single string.
to: [string]
d
For the purpose of the first test I hard coded the keys in graphcool.yml just until I can figure out what graphcool wants for an environment file
Copy code
sendEmail:
    handler:
      code:
        src: src/ses/sendEmail.ts
        environment:
          ACCESS_KEY_ID: ****************
          SECRET_ACCESS_KEY: *****************
          REGION: us-east
    type: resolver
    schema: src/ses/sendEmail.graphql
I appreciate the help
m
you can use environ vars
Copy code
AWS_BUCKET_GP_FILES: ${env:AWS_BUCKET_GP_FILES}
          AWS_DEFAULT_REGION: ${env:AWS_DEFAULT_REGION}
          S3_AWS_ACCESS_KEY_ID: ${env:S3_AWS_ACCESS_KEY_ID}
          S3_AWS_SECRET_ACCESS_KEY: ${env:S3_AWS_SECRET_ACCESS_KEY}`
then use direnv to load the vars
if you're using linux/macOs that is
i.e.
Copy code
sendEmail:
    handler:
      code:
        src: src/ses/sendEmail.ts
        environment:
          ACCESS_KEY_ID: ${env:ACCESS_KEY_ID}
          SECRET_ACCESS_KEY: ${env:SECRET_ACCESS_KEY}
          REGION: ${env:REGION}
    type: resolver
    schema: src/ses/sendEmail.graphql
d
I am using macOS. I saw the mention in the docs about direnv, I’ll have to look into it to use it
@max your comment on the to line made a difference. Once I changed my to from a string to a string in an array my error message changed.
Copy code
2018-01-25T20:22:57.286Z 2163ms FAILURE {
  "error": "The resolver function `sendEmail` is not nullable, but the function returned null."
m
cool so the function is running 🙂 what are you returning?
maybe insert some console logs to debug it. and check the logs
@Daniel Carroll
d
Trying to see if I can get it to log some debugging, I’ll report back if I have any success
m
you know to use
gc logs -f nameOfFunc
right?
d
Yep, I have it up right now, that most previous error is output from graphcool-framework logs -f sendEmail --tail