GraphQL Query string to LINQ Expression
See original GitHub issueHi,
This library looks awesome. Apologies in advance if I’ve missed something here. I’ve spent some time looking through the examples on the front page but wasn’t sure how to do this. What I’m looking for is a way to retrieve a LINQ Expression from a GraphQL string query. This would be totally decoupled from EF or even IQueryable.
The delegate would look exactly like this:
delegate Expression GetExpression(string graphQl);
Or potentially this with generics:
delegate Expression<Func<T, bool>> GetExpression<T>(string graphQl);
Is there a straight forward way to implement this delegate with this library?
Christian
Issue Analytics
- State:
- Created 3 years ago
- Comments:13
Top Results From Across the Web
GraphQL Query string to LINQ Expression · Issue #59
What I'm looking for is a way to retrieve a LINQ Expression from a GraphQL string query. This would be totally decoupled from...
Read more >Mapping GraphQL query to Select() linq to sql
The best strategy here is using Select() to specific properties we need to fetch. But I have no idea how to build the...
Read more >Introducing GraphQLinq - Strongly Typed GraphQL ...
To view the generated GraphQL query, call ToString on the LINQ query itself. You will get the GraphQL query together with the variables...
Read more >Library to compile GraphQL to LINQ expressions (EF ...
I thought I'd share a library I have been working on and use in production for some time. Ultimately I'd love some feedback....
Read more >C# Linq for GraphQL queries
Putting it all together, I got a mechanism that allows using Expressions to form the correct GraphQL string for a subsequent request to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
hey @MelbourneDeveloper , just looking at this now.
First you do not need to use
DbContext
you could build a schema from scratch fromobject
type of a custom type like it looks like you have done. This library just builds LINQ expressions against an object structure. If that happens to be aDbContext
then you get those benefits.So you are building a schema from
PeopleDbContext
can you post that too?When you compile
person.where(name = ""{name}"")
againstPeopleDbContext
it will look for a property/field calledperson
.Also
person.where(name = ""{name}"")
is not valid GraphQL, but you are usingEntityQueryCompiler
which allows this so that’s good, just wanted to spell that out though.EntityQueryCompiler by itself is, well, less tested.
You should be able to take the
compiledQueryResult.LambdaExpression
which should be an expression like(Person p) => p.Where(t => t.Name == "...")
Note that perhaps you mean
people.where()
? But that depends on how you defined the schema or thePeopleDbContext
class.If you can provide a sample project I’d happily have a quick look.
sure thing.