我创建了一个 AWS AppSync graphql api,它在被调用时将运行一个 AWS Lambda 函数,该函数将使用查询语言 Gremlin 创建一个顶点和边,但是在成功创建顶点后我无法创建边,并且 AWS AppSync 给了我这个错误 “消息”:“g.addE(...).from 不是函数”
这是我的 lambda 函数代码,如果我的代码有问题,请检查一下?告诉我我的错误在哪里?
import { process as gprocess } from 'gremlin';
import Post from './Post'
const gremlin = require('gremlin')
const DriverRemoteConnection = gremlin.driver.DriverRemoteConnection
const Graph = gremlin.structure.Graph
const uri = process.env.WRITER
const { t, P, } = gprocess;
const __ = gprocess.statics;
async function createPost(post: Post) {
let dc = new DriverRemoteConnection(`wss://${uri}/gremlin`, {})
const graph = new Graph()
const g = graph.traversal().withRemote(dc)
let vertex = await g.addV('posts').property('title',post.title).property('content', post.content).property('id', post.id).next()
let edge = await g.addE('post_to_post').from(g.V().hasLabel('posts').next()).to(g.V().hasLabel('posts').next()).next()
dc.close()
return post;
}
export default createPost