Skip to content

Commit

Permalink
Fix http gremlin queries resulting in bad request (aws#37)
Browse files Browse the repository at this point in the history
Changed http lambda code to submit axios POST gremlin query request with body as object instead of string to solve 400 bad request errors and then changed open cypher axios POST request as well for consistency.
  • Loading branch information
andreachild authored and sophiadt committed Nov 20, 2024
1 parent 39b4ea5 commit 315cc5e
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions templates/Lambda4AppSyncHTTP/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,15 @@ export const handler = async (event) => {
timeout: 20000
};

if (resolver.language == 'opencypher') {
result = await axios.post(`https://${process.env.NEPTUNE_HOST}:${process.env.NEPTUNE_PORT}/opencypher`, `query=${encodeURIComponent(resolver.query)}&parameters=${encodeURIComponent(JSON.stringify(resolver.parameters))}`, myConfig);
if (resolver.language === 'opencypher') {
result = await axios.post(`https://${process.env.NEPTUNE_HOST}:${process.env.NEPTUNE_PORT}/opencypher`, {
query: resolver.query,
parameters: JSON.stringify(resolver.parameters)
}, myConfig);
} else {
result = await axios.post(`https://${process.env.NEPTUNE_HOST}:${process.env.NEPTUNE_PORT}`, `gremlin=${encodeURIComponent(resolver.query)}`, myConfig);
result = await axios.post(`https://${process.env.NEPTUNE_HOST}:${process.env.NEPTUNE_PORT}/gremlin`, {
gremlin: resolver.query
}, myConfig);
}
if (LOGGING_ENABLED) console.log("Result: ", JSON.stringify(result.data, null, 2));
} catch (err) {
Expand Down

0 comments on commit 315cc5e

Please sign in to comment.