Comments (11)
Just noticed this is the functions
repo. For the future, please report errors like this in https://github.com/graphcool/api-bugs/
instead. Let's discuss this error here though π
from graphcool-templates.
FYI, able to neither create new nor update existing functions.
from graphcool-templates.
Yes I was about to say as much. This behaviour is observed when you have a syntax error in the function itself, or we were not able to import a specified npm module or similar.
We're already working on returning a user friendly error message in these cases instead π Could you check your code for syntax errors? (might be a missing bracket or brace, for example)
from graphcool-templates.
Thanks! Will check the code again.
from graphcool-templates.
Ok. FYI, hereβs the query
and function
.
subscription {
User(filter: {
mutation_in: [CREATED]
}) {
updatedFields
node {
id
firstName
lastName
email
isPaid
}
}
}
module.exports = function (event) {
var sg = require("[email protected]")(___SENDGRID_API___)
var request = sg.emptyRequest()
request.body = [{
"email": event.data.node.email,
"first_name": event.data.node.firstName,
"last_name": event.data.node.lastName,
"LPA_paid": event.data.node.isPaid,
"SOURCE": "LPA"
}];
request.method = "POST"
request.path = "/v3/contactdb/recipients"
return new Promise(function(resolve, reject) {
sg.API(request, function (error, response) {
if (error) {
console.log("Error response received")
reject(error)
}
console.log(response.statusCode)
console.log(response.body)
console.log(response.headers)
resolve(response)
})
}
}
from graphcool-templates.
Can you try
var sg = require("sendgrid")(___SENDGRID_API___)
instead of
var sg = require("[email protected]")(___SENDGRID_API___)
from graphcool-templates.
Is the API key wrapped as a "string"? Tried both.
from graphcool-templates.
yes, it is
from graphcool-templates.
For reference: https://github.com/sendgrid/sendgrid-nodejs/blob/master/examples/contactdb/contactdb.js#L253-L279
from graphcool-templates.
Per @marktani: You missed a )
in the second last line, this is the correct code you need to use
module.exports = function (event) {
var sg = require("sendgrid")(___SENDGRID_API_KEY___)
var request = sg.emptyRequest()
request.body = [{
"email": event.data.node.email,
"first_name": event.data.node.firstName,
"last_name": event.data.node.lastName
}];
request.method = "POST"
request.path = "/v3/contactdb/recipients"
return new Promise(function(resolve, reject) {
sg.API(request, function (error, response) {
if (error) {
console.log("Error response received")
reject(error)
}
console.log(response.statusCode)
console.log(response.body)
console.log(response.headers)
resolve(response)
})
})
}
from graphcool-templates.
Thanks!
from graphcool-templates.
Related Issues (20)
- Facebook Delegated Account Recovery
- Google auth mutation is not working HOT 3
- Auth-templates for Linkedin and Twitter HOT 2
- Templates should be written in TypeScript HOT 4
- Create language branches so people can easily contribute in their own programming language
- Email-password authentication returning an unhandled error HOT 2
- Auth0 authentication broken on React Native HOT 2
- Email / Password template : Passwords revealed in function error logs HOT 2
- Utility functions in a template - Please vote HOT 3
- jwt.decode fails on new id_tokens
- Question: Can this be used via an SPA and without Auth0 Lock? HOT 4
- Authentication template for Gitlab users
- Slack Bot command handling support
- Auth template for Twitch
- Should I PR an updated SMS authentication with Twilio? HOT 1
- Can't distinguish expired tokens from empty responses
- Add template and GraphCool.yml no longer working
- Token produced no longer works with GraphCool
- Passwords are stored in clear locally (no hash) HOT 2
- OAuth 2.0 support for linkedin auth-template
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from graphcool-templates.