Im trying to achieve transaction management in cosmos gremlin. Like i should be able to create some nodes and edges in a single transaction, if one of the operation fails the entire transaction should be discarded, like in sql terms commit and rollback. Would i be able to achieve that ?
I tried using DriverRemoteConnection from gremlin driver, which seems to have commit and rollback, but i cant run any queries using connection.submit(), because this strictly uses Bytecode traversal, which is an unsupported feature of cosmos gremlin https://learn.microsoft.com/en-us/azure/cosmos-db/gremlin/support#unsupported-features.
im using node gremlin package
export const connection : driver.DriverRemoteConnection = new driver.DriverRemoteConnection(
endpoint,
{
authenticator,
traversalsource: 'g',
rejectUnauthorized: true,
mimeType: 'application/vnd.gremlin-v2.0+json',
}
);
const query = "g.addV('TEST').property('id', 'test').property('partitionKey', 'test').property('name', 'test')";
await connection.open();
const res1 = await connection.submit(query) // fails here saying 'Argument of type 'string' is not assignable to parameter of type 'Bytecode''
await connection.commit();
So, i changed my approach little bit using process.traversal from gremlin package
const tx = process.traversal().withRemote(connection).tx();
const g = tx.begin();
const res1 = await g.addV('VMER').property('id', '2').property('partitionKey', '2').iterate();
Logger.info('Query executed successfully', res1);
await tx.commit();
this fails with below error
Stack: ResponseError: Server error:
[2024-10-29T10:26:46.172Z]
[2024-10-29T10:26:46.172Z] ActivityId : 8cfb0fcf-7ae1-42c5-9759-d1aa7b23f984
[2024-10-29T10:26:46.172Z] ExceptionType : GraphMalformedException
[2024-10-29T10:26:46.172Z] ExceptionMessage :
[2024-10-29T10:26:46.172Z] Gremlin Malformed Request: Unsupported request operation: 'bytecode'.
[2024-10-29T10:26:46.173Z] GremlinRequestId : e1dda306-ac20-454f-a9c0-7c075c75923b
[2024-10-29T10:26:46.173Z] Context : global
[2024-10-29T10:26:46.173Z] GraphInterOpStatusCode : MalformedRequest
[2024-10-29T10:26:46.173Z] HResult : 0x80131500
Any suggestions?