微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

无法从 AWS Neptune 检索数据

如何解决无法从 AWS Neptune 检索数据

我创建了一个 AWS Appsync graphql api,它在被调用时将运行 aws lambda 函数,该函数将使用查询语言 Gremlin 从 AWS Neptune 查询数据,但我无法从 aws neptune 检索数据。

这是我的 lambda 函数

// 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


这是我的架构

type HighestRatedRestaurantWithSpecificCuisine {
    name : String
    address : String
    cuisine : String
    rating_average : String
}

type Query {
 getHighestRatedRestaurantWithSpecificCuisine : HighestRatedRestaurantWithSpecificCuisine
}

每当通过 appsync 进行查询时,它都会返回 null,但是当我在 AWS CloudWatch 中对其进行控制台时,它包含表单中的数据

    Data>>> Map {
  'name' => 'Burger Lab','address' => '3648 Alek Forge','rating_average' => '4','cuisine' => 'Burgers' }


版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。