I have created an AWS Appsync graphql api which on being called will run an aws lambda function and that function will query data from AWS Neptune using query language Gremlin but i am unable to retrieve data from aws neptune.
This is my lambda function
// import * as gremlin from "gremlin";
const gremlin = require("gremlin")
const DriverRemoteConnection = gremlin.driver.DriverRemoteConnection;
const Graph = gremlin.structure.Graph;
const uri = process.env.READER_ENDPOINT
const HighestRatedByCuisine = async () => {
let dc = new DriverRemoteConnection(`wss://${uri}/gremlin`, {});
const graph = new Graph();
const g = graph.traversal().withRemote(dc)
try {
let data = await g.V().has("Person", "name", "Muhammad Ahsen Riaz").
out("lives").in_("within").where(__.out("serves").
has("name", P.within("Burgers"))).
where(__.inE("about")).
group().
by(__.identity()).
by(__.in_("about").values("rating")).
order().
by(values, Order.desc).
unfold().
order().by(values, Order.desc).limit(1).
project("name", "address", "rating_average", "cuisine").
by(__.select(Column.keys).values("name")).
by(__.select(Column.keys).values("address")).
by(__.select(Column.values)).
by(__.select(Column.keys).out("serves").values("name")).next()
console.log("Onlydata" , data)
console.log("Data>>>" , data.value)
console.log("data>>>>>" , data.done)
console.log("JsonData" , JSON.stringify(data))
return data.value
}
catch (err) {
console.log("there is an error " , err)
return err
};
}
export default HighestRatedByCuisine
where as this is my schema
type HighestRatedRestaurantWithSpecificCuisine {
name : String
address : String
cuisine : String
rating_average : String
}
type Query {
getHighestRatedRestaurantWithSpecificCuisine : HighestRatedRestaurantWithSpecificCuisine
}
Whenever a query throught appsync it returns null but when i console it in AWS CloudWatch it contains data in the form
Data>>> Map {
'name' => 'Burger Lab',
'address' => '3648 Alek Forge',
'rating_average' => '4',
'cuisine' => 'Burgers' }