0

On Loopback 3, I can use api for nested queries like these one:

http://localhost/api/ServiceOrders?filter={
    "where": { "id" : 4 } , 
    "include": [  
         { "itemModel" : "itemBrand" }, 
         "itemSize"   ]    
    }  

For Loopback4 I am trying...

http://localhost/ServiceOrders?filter={
    "where": { "id": 4 }, 
    "include": [ 
        { 
           "relation": "itemModel", 
            "scope": {  
                "include": [ { "relation": "itemBrand"} ]
             }   
         }  
     ] 
}

but returns "scope" is not supported

ps: Loopback4 sintax based on Loopback 4 include nested relations post.

thanks, regards

fhansen
  • 43
  • 6

1 Answers1

0

Updated to @loopback/cli version 2.0.1 (I dont know if this helps)

Working api:

http://localhost:3000/service-order?filter={  
      "where": { "modifiedOn": { "gt":  "2020-01-01"  } }, 
      "include": [{ 
                    "relation":  "itemModel", 
                    "scope": { "include":[{"relation":"itemBrand"}] } 
                  },
                  { "relation":  "itemSize" }
                 ]  }

Also checked if every relation contains following lines on repositories:

  this.itemBrand= this.createBelongsToAccessorFor('itemBrand', itemBrandRepositoryGetter,);
  this.registerInclusionResolver('itemBrand', this.itemBrand.inclusionResolver);
fhansen
  • 43
  • 6