Skip to content

Please support val function on facets #4520

@ChStark

Description

@ChStark

What you wanted to do

If we have an upsert block like:

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> (quantity=5, price=val(regular_price), tax=val(regular_tax) ) .
    }
  }
} 

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Stalearea/facetsIssues related to face handling, querying, etc.area/querylangIssues related to the query language specification and implementation.area/querylang/varsIssues related to queries with GraphQL variablesarea/upsertIssues related to upsert operations.kind/featureSomething completely new we should consider.priority/P3Low priority, something to be done once everything else seems fixed.status/acceptedWe accept to investigate/work on it.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions