Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/Service.Tests/CosmosTests/CosmosTestHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ public static object GetItem(string id, string name = null, int numericVal = 4)
name = "planet character",
type = "Mars",
homePlanet = 1,
primaryFunction = "test function"
primaryFunction = "test function",
star = new
{
name = name + "_star"
}
}
};
}
Expand Down
36 changes: 36 additions & 0 deletions src/Service.Tests/CosmosTests/QueryFilterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,9 @@ public async Task TestFilterOnNestedFields()
name
homePlanet
primaryFunction
star{
name
}
}
}
}
Expand Down Expand Up @@ -594,6 +597,9 @@ public async Task TestFilterOnNestedFieldsWithAnd()
name
homePlanet
primaryFunction
star{
name
}
}
}
}
Expand All @@ -603,6 +609,36 @@ public async Task TestFilterOnNestedFieldsWithAnd()
await ExecuteAndValidateResult(_graphQLQueryName, gqlQuery, dbQuery);
}

/// <summary>
/// Test filters on nested object
/// </summary>
[TestMethod]
public async Task TestFilterOnInnerNestedFields()
{
string gqlQuery = @"{
planets(first: 1, " + QueryBuilder.FILTER_FIELD_NAME + @" : {character : {star : {name : {eq : ""Endor_star""}}}})
{
items {
id
name
character {
id
type
name
homePlanet
primaryFunction
star{
name
}
}
}
}
}";

string dbQuery = "SELECT top 1 c.id, c.name, c.character FROM c where c.character.star.name = \"Endor_star\"";
await ExecuteAndValidateResult(_graphQLQueryName, gqlQuery, dbQuery);
}

[ClassCleanup]
public static void TestFixtureTearDown()
{
Expand Down
3 changes: 2 additions & 1 deletion src/Service.Tests/CosmosTests/TestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ type Character @model(name:""Character"") {
name : String,
type: String,
homePlanet: Int,
primaryFunction: String
primaryFunction: String,
star: Star
}

type Planet @model(name:""Planet"") {
Expand Down
3 changes: 2 additions & 1 deletion src/Service/schema.gql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ type Character @model(name:"Character") {
name : String,
type: String,
homePlanet: Int,
primaryFunction: String
primaryFunction: String,
star: Star
}

type Planet @model(name:"Planet"){
Expand Down