byme8 / ZeroQL

C# GraphQL client with Linq-like syntax
MIT License
278 stars 13 forks source link

Add support for reading variables from lambda closure. #39

Closed byme8 closed 1 year ago

byme8 commented 1 year ago

At the moment we need to define a separate variable to pass variables into the GraphQL query:

var variables = new { UserId = 10 };
var response = await client.Query(variables, (i,q) => q.User(i,UserId, u => i.FirstName));

It works fine and have excellent performance, because there is no need for any expressions.

This pull request investigates ways to add support for syntax where there is no need for additional variable. Values are got from the lambda closure itself:

var userId = 10;
var response = await client.Query(q => q.User(userId, u => i.FirstName));