Skip to content

Commit 1fe99c2

Browse files
Issue-34 formatter of query string builder (#35)
* Update QueryOf{T}.cs issue-34 - Updated the Query to pass the options.Formatter to the QueryStringBuilder * Update CustomQueryStringBuilderTests.cs issue-34 - added the Test for the Argument objects formatting verification
1 parent 481cc90 commit 1fe99c2

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/GraphQL.Query.Builder/QueryOf{T}.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ public Query(string name, QueryOptions options)
4747
{
4848
this.QueryStringBuilder = options.QueryStringBuilderFactory();
4949
}
50+
else if (options?.Formatter != null)
51+
{
52+
this.QueryStringBuilder = new QueryStringBuilder(options.Formatter);
53+
}
5054
}
5155

5256
/// <summary>Sets the query alias name.</summary>

tests/GraphQL.Query.Builder.UnitTests/CustomQueryStringBuilderTests.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,25 @@ private static string ToConstantCase(string name)
5959
return result;
6060
}
6161
}
62+
63+
[Fact]
64+
public void TestArgumentsWithCamelCasePropertyNameFormatter()
65+
{
66+
QueryOptions options = new()
67+
{
68+
Formatter = CamelCasePropertyNameFormatter.Format
69+
};
70+
string query = new Query<object>("something", options)
71+
.AddArguments(new
72+
{
73+
SomeObject = new
74+
{
75+
InnerObjectField = "camel case"
76+
}
77+
})
78+
.AddField("some")
79+
.Build();
80+
81+
Assert.Equal("something(someObject:{innerObjectField:\"camel case\"}){some}", query);
82+
}
6283
}

0 commit comments

Comments
 (0)