Hello everyone,
I’ve got several questions regarding “update” mutation. I have a setup, where most of the transactions will be “update mutation” & simple queries. First step is to add some nodes & relationships, second one is to update & query them very frequently, but I’ve found several issues regarding the update:
- I’ve found out that dGraph doesn’t support update of multiple nodes at once (Cannot update multiple nodes at once). I would like to update nodes 30-50 times per second. Some of the nodes will get 5 updates & some of them will get 1 update. If there is a way to achieve this, I would like to know how (whether it is DQL or GraphQL).
- I’ve tested Subscriptions directive, it works fine, but the update mutation doesn’t trigger the query subscription (addType & deleteType trigger the query normally). Here is the code, I’ve used:
Schema:
type Sensor @withSubscription {
id: ID!
xid: String! @id @search
value: Int @search
timestamp: DateTime
unit: String
}
Subscription code:
from python_graphql_client import GraphqlClient
client = GraphqlClient(endpoint="ws://localhost:8080/graphql", verify=False)
query = """subscription testSubscription {
querySensor {
xid
}
}
"""
# Asynchronous request
import asyncio
asyncio.run(client.subscribe(query=query, handle=print))
Add/update/delete code:
from python_graphql_client import GraphqlClient
client = GraphqlClient(endpoint="http://localhost:8080/graphql")
addSensor= """mutation MyMutation {
addSensor(input: {xid: "customSensor", value: 10, timestamp: "2023-02-22T09:49:57Z", unit: "C", type: "temperature"}) {numUids}
}"""
updateSensor = """mutation MyMutation {
updateSensor(input: {filter: {xid: {allofterms: "customSensor"}}, set: {value: 10}}) {numUids}
}"""
deetelSensor = """mutation MyMutation {
deleteSensor(filter: {xid: {allofterms: "customSensor"}}) {
numUids
}
}
"""
data = client.execute(query=updateSensor)
Thanks in advance!