Unable to use Hot Chocolate sorting
See original GitHub issueNot sure if this is the same issue that I mentioned in #11 as being obscured, but it seems like it. In the first case, it was calling a mutation with a complex parameter and the same is in this case. All both of these issues could very well be syntax errors on my part, but I can’t figure it out after much review of your documentation.
So, I’m simplified this problem down as much as possible and created a repo that reproduces the issue. I’ve made a GraphQL test server that just exposes a simple Author
class and has a query to get a list of authors. I added Hot Chocolate’s sorting attribute on it. Anyhow, I cannot get the ZeroQL client to compile when trying to provide a sorting criteria.
var sortResponse = await qlClient.Query(static query => query.Authors(new AuthorSortInput[] { new AuthorSortInput { Name = SortEnumType.Asc } }, o => o.Name));
If I don’t provide a sorting argument, then it compiles and runs in the Test Explorer just fine:
var noSortResponse = await qlClient.Query(static query => query.Authors(null, o => o.Name));
If you clone the repo at https://github.com/Servant-Software-LLC/ZeroQL_Can_Not_Sort_Hot_Chocolate, it has the GraphQL server, generator and XUnit test which doesn’t compile in the latest commit.
Issue Analytics
- State:
- Created a year ago
- Comments:6 (6 by maintainers)
@byme8, Wonderful! I now have a working solution whose unit tests pass. Converting the variable json strings values were a blocker for a long while, but I found that Hot Chocolate provides an
IHttpRequestParser
service that I could make use of to get the proper variables dictionary instance.Anyhow, I’ve push the latest commit https://github.com/Servant-Software-LLC/ZeroQL_Can_Not_Sort_Hot_Chocolate/commit/ef366f7b709ad8bd435d3853ddf0ed97d56bb073 to the repo in case anyone else comes across this and needs an example of integration tests that don’t need an HTTP endpoint stood up in order for them to execute against their GraphQL server.
Thanks again, David
To pass complex objects, you have to use the input variables. It is essential to do it like that because there is no direct mapping from complex object to graphql literal.