Skip to content

Instantly share code, notes, and snippets.

@r3-yamauchi
Created August 5, 2019 03:34
Show Gist options
  • Save r3-yamauchi/e18f41a5d5bedf57592ecaf870507796 to your computer and use it in GitHub Desktop.
Save r3-yamauchi/e18f41a5d5bedf57592ecaf870507796 to your computer and use it in GitHub Desktop.
const getMovies = `query GetMovies{
getMovies(id: 0) {
id
name
poster
date
plot
}
}
`;
const invokeGetMovie = async () => {
let req = new AWS.HttpRequest(appsyncUrl, env.AWS_REGION);
req.method = 'POST';
req.headers.host = endpoint;
req.headers['Content-Type'] = 'multipart/form-data';
req.body = JSON.stringify({
query: getMovies,
operationName: 'GetMovies'
});
let signer = new AWS.Signers.V4(req, 'appsync', true);
signer.addAuthorization(AWS.config.credentials, AWS.util.date.getDate());
const result = await axios({
method: 'post',
url: appsyncUrl,
data: req.body,
headers: req.headers
});
return result;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment