I have created an AWS AppSync graphql api which on being called will run an AWS Lambda function and that function will create a vertex and edge using query language Gremlin but I am unable create edge after vertex is successfully created and AWS AppSync giving me this error "message": "g.addE(...).from is not a function"
This is my lambda function code please check it if there is any problem in my code? tell me where is my mistake?
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