Skip to content

Commit

Permalink
Do not return empty arrays with GraphQL filter
Browse files Browse the repository at this point in the history
  • Loading branch information
ttu committed Sep 30, 2018
1 parent 65afa4b commit 221dd91
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Fix for HEAD method use and ETag to support HEAD method
* .NET Core version to 2.1
* Support for objects
* Do not return empty arrays with GraphQL filter

### [0.6.0] - 2017-11-30
* Caching of unchanged resources with ETag and If-None-Match headers
Expand Down
2 changes: 2 additions & 0 deletions FakeServer.Test/GraphQLTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public void Query_Families()

Assert.NotEmpty(js);

Assert.Equal(4, results.Data["families"].Count);

UTHelpers.Down(filePath);
}

Expand Down
5 changes: 4 additions & 1 deletion FakeServer/GraphQL/GraphQL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ private static ExecutionResult ResolveField(dynamic source, dynamic target, Fiel
var r = ResolveField(item, rootObject, i.Value);
rootObject = r.Data;
}

if (rootObject != null)
result.Add(rootObject);
}
Expand Down Expand Up @@ -332,6 +332,9 @@ private static ExecutionResult ResolveField(dynamic source, dynamic target, Fiel
if (rootObject != null)
newArray.Add(rootObject);
}

if (f.Arguments.Any() && newArray.Count == 0)
target = null;
}
else
{
Expand Down

0 comments on commit 221dd91

Please sign in to comment.