@JatinDevDG - Are there plans to add @id to the DQL layer?
Hi @eugaia, no @id fields are completely GraphQL features that are implemented using DQL upsert mutations. And there is no plan to add it in DQL as of now because same effect can be achieved upsert mutations.
Basically, the @id field is just a normal field but while adding or updating it we make a query to check whether there is a node with the same value already, exist or not. If you want to have such behaviour, you need to write your own upsert block.
https://dgraph.io/docs/mutations/conditional-upsert/
@JatinDevDG - Thanks.
Is there a way using conditional upserts to perform the same action on every predicate of the same name in say a ‘set’ operation?
e.g. You’re if you’re importing 10 million RDF triples about 1 million nodes, is there a way using conditional upserts to automate the checking of every predicate ‘myID’ to check for uniqueness, or would you need to generate a separate upsert command for each node to check that the ‘myID’ field value is unique?
I guess that’s not possible while importing. DQL guys will tell more.
@MichelDiz any idea?
Thanks. I have a second question too:
Assuming we have two parallel upsert requests to insert a value to the myID predicate that both want to set the same value ‘someID’. If there’s a race condition such that both of them see that there is no other node with a myID value set to ‘someID’ as part of the query block of the upsert, when one of those transactions commits, will the other transaction automatically commit without checking the myID predicate again for a value ‘someID’ or will the value be checked for again before committing (to guarantee uniqueness of myID at the point of committing, not just the point of querying)?
Thanks.
Not while importing. But there is a feature in Live loader related to XIDs(Blank nodes, unique identifiers). If you use it, it will create an upsert block based on the identifier in the RDF. This is a bit different but provides uniqueness via live loader.
You can use the directive @upsert
which guarantees these concurrent(Conflicts) behaviors. Read Upserts - Howto
@MichelDiz - Thanks.
just FYI - i’m messing around on a starter/free instance of dgraph cloud and this feature is not available there yet. adding two @id
generates this error:
… but a type can have only one field with @id. Pick a single field with @id for type …
Hi @RickSalmon , Welcome to Dgraph community!!
This feature is available in 21.03 release and cloud is currently using 20.11.
We are upgrading cloud to 21.03 that will be done in 2-3 weeks.