steveb
04/06/2018, 5:29 PMgraphcool/graphql-request
from inside a lambda?nilan
04/06/2018, 6:18 PMsteveb
04/06/2018, 6:45 PMsteveb
04/06/2018, 6:46 PMsteveb
04/06/2018, 6:46 PMconst mutation = `mutation {
createMessage(data:{
issue:{
connect:{
id: "${issueId}"
}
}
body:"test"
}){
id
}
}`
console.log(mutation)
const jwt = await getJWT()
const client = new GraphQLClient(_ENDPOINT, {
headers: {
Authorization: 'Bearer ' + jwt
}
})
client
.request(mutation)
.then(async data => {
console.log(data)
if (data) {
// delete the email from S3
const deleted = await delS3File(emailFile)
console.log('Execution Complete - S3 file deleted')
}
})
.catch(err => {
console.log(err.response.errors) // GraphQL response errors
console.log(err.response.data) // Response data if available
})
steveb
04/06/2018, 6:46 PMsteveb
04/06/2018, 6:47 PMsteveb
04/07/2018, 2:23 PMawait
instead of the .then/.catch. also needed to set mode: 'cors'
nilan
04/09/2018, 11:54 AM