const axios = require('axios');
const gql = require('graphql-tag');
const graphql = require('graphql');
const { print } = graphql;
const listTodos = gql`
query listTodos {
listTodos {
items {
id
name
description
}
}
}
`
exports.handler = async (event) => {
try {
const graphqlData = await axios({
url: process.env.API_URL,
method: 'post',
headers: {
'x-api-key': process.env.API_<YOUR_API_NAME>_GRAPHQLAPIKEYOUTPUT
},
data: {
query: print(listTodos),
}
});
const body = {
graphqlData: graphqlData.data.data.listTodos
}
return {
statusCode: 200,
body: JSON.stringify(body),
headers: {
"Access-Control-Allow-Origin": "*",
}
}
} catch (err) {
console.log('error posting to appsync: ', err);
}
}
const axios = require('axios');
const gql = require('graphql-tag');
const graphql = require('graphql');
const { print } = graphql;
const listTodos = gql`
query listTodos {
listTodos {
items {
id
name
description
}
}
}
`
exports.handler = async (event) => {
try {
const graphqlData = await axios({
url: process.env.API_URL,
method: 'post',
headers: {
'x-api-key': process.env.API_<YOUR_API_NAME>_GRAPHQLAPIKEYOUTPUT
},
data: {
query: print(listTodos),
}
});
const body = {
graphqlData: graphqlData.data.data.listTodos
}
return {
statusCode: 200,
body: JSON.stringify(body),
headers: {
"Access-Control-Allow-Origin": "*",
}
}
} catch (err) {
console.log('error posting to appsync: ', err);
}
}