Using the graphql mutation this is working and respect the uniqueness by returning an error: "message": "couldn't rewrite mutation addProduct because failed to rewrite mutation payload because id aaaa already exists for field name inside type Product"
You can’t mix the same logic of GraphQL with DQL. GraphQL works in a way almost “automatic” and DQL is “by hand”. No DQL query or mutation will check any GraphQL logic. You have to build an Upsert Query based on the GraphQL logic. So it would kind of “respect” the GraphQL data modeling.
Well, you should Pick only GraphQL if you are using GraphQL and you will have these guarantees. For DQL, an Upsert Logic should be fine. We have DQL working like this for years. Just a few people complained about it in 4 years and once they learned how to, they get used to it.
The Upsert logic is
1 - A Block to check the existing data. And use variables to capture that info.
2 - A Block to mutate the data based on the data within the variables.
PS. You have also to pay attention to the Data Modeling in GraphQL. Which is standardized for GraphQL’s context. Mean, the mutation modeling has its rules. You may find them on docs or here in the community posts. In DQL the data modeling is completely free to model.
Think of this GraphQL implementation like GraphQL on top of the likes of DynamoDB or MongoDB in that there are not very many rules at all that DQL has to follow, but this is better than any of those options because it then builds the API rules into a single layered db/api. So it is the somewhat best of both worlds but uniquely its own.
In a simple analogy: GraphQL is to Samurai(bureaucracy and honor the types) as DQL is to Ninja(work in the shadows and does tricks freely - also “With great power, there must also come great responsibility” as said Stan Lee).
“Master both languages, you have, to great warrior be” Grand Master Yoda on Dgraph.