has anyone ever used `graphcool/graphql-request` f...
# prisma-whats-new
s
has anyone ever used
graphcool/graphql-request
from inside a lambda?
n
yup - what is your situation?
s
Just seems like it's never actually making the request
here's how i am using it:
Copy code
const 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
    })
not seeing it hit the graphql server
didn't know if there were any known issues with using it in a lambda
Got it working, ended up switching to an
await
instead of the .then/.catch. also needed to set
mode: 'cors'
👍 1
n
nice! I didn't know about the cors mode