Closed ChStark closed 2 weeks ago
Although issue #1996's proposal is different, it has a similar goal.
Maybe we can achieve the goal of both issues changing the syntaxis (have inmmutability and consistency on the edge attributes and the ability to use val)
upsert{
query{
product( func: uid( 0x12a4f4e ) ){
wholesale_price as product.wholesale_price
wholesale_tax as product.wholesale_tax
regular_price as product.regular_price
regular_tax as product.regular_tax
}
user( func: uid( 0x12a4f31 ) ){
is_wholesaler as user.is_wholesaler
}
}
mutation @if( eq( val(is_wholesaler) , true ) ){
set{
<0x12a4f31> <user.orders> <0x12a4f55> .
<0x12a4f55> <order.products> <0x12a4f4e> (quantity=5, price=val(wholesale_price), tax=val(wholesale_tax) ) .
}
}
mutation @if( not( eq( val(is_wholesaler) , true ) ) ){
set{
<0x12a4f31> <user.orders> <0x12a4f55> .
<0x12a4f55> <order.products> <0x12a4f4e> 5#quantity .
<0x12a4f55> <order.products> <0x12a4f4e> val(regular_price)#price .
<0x12a4f55> <order.products> <0x12a4f4e> val(regular_tax)#tax .
}
}
}
Doing something like this we can have something that currently works ( val on values of nquad ) and indicate to the parser what specific facet we want to mutate to change only that one and not to mutate the other ones
This issue has been stale for 60 days and will be closed automatically in 7 days. Comment to keep it open.
What you wanted to do
If we have an upsert block like:
It wont work since the val function is not supported on facets
What you actually did
The work around is to do a 2 part job, one to query the data and one to do the mutation, but since dgraph wants to reduce the network trips, I thinks this should be supported
Why that wasn't great, with examples
It wasn't great that I had to handle more logic on the app just because the QL doesn't support the parsing of a function