question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Query GraphQL with LINQ

See original GitHub issue

I’m not sure whether this feature belongs to this project or not but I wanted to share my suggestion and a prototype I built.

Problem:

Querying a GraphQL endpoint requires writing a string query that is neither strongly typed, nor checked by the compiler. As LINQ solved the same problem it would be cool to do use LINQ for GraphQL queries too.

Solution

I have built a prototype called GraphQLinq that generates strongly typed client from GraphQL API and allows writing graphQL queries like this:

var spaceXContext = new QueryContext();
var companySummary = spaceXContext.Company().Select(c => new CompanySummary
{
    Ceo = c.Ceo,
    Name = c.Name,
    Headquarters = c.Headquarters
}).ToItem();

This will generate a GraphQL query, run it and deserialize response in the corresponding class.

It supports quering nested properties and you can find more examples in the Readme of the project.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
rojicommented, Apr 28, 2021

We’re definitely interesting in anything GraphQL and .NET, thanks for opening this and for the discussion. Please don’t hesitate to ping me or the rest of the team for anything.

1reaction
Giorgicommented, Apr 28, 2021

We can move to the project repo for more details. I opened it here because EF Core 6 plans mentioned GraphQL and wanted to bring the project to the ef team’s attention.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Introducing GraphQLinq - Strongly Typed GraphQL ...
Running GraphQL Queries with LINQ ... The scaffolding tool generates QueryContext class that serves as an entry point for writing and running LINQ...
Read more >
LINQ to GraphQL Data
LINQ provides general-purpose query facilities in .NET Framework 3.0 and above and provides one easy way to programmatically access data through from CData ......
Read more >
Strongly-Typed GraphQL Queries with LINQ to ...
I want to introduce my project - GraphQLinq that allows you to write graphQL queries with LINQ. It also includes a .
Read more >
Mapping GraphQL query to Select() linq to sql
I am building an Web API with .NET core using GraphQL and DocumentDb . In theory, GraphQL is optimized the data is shipped...
Read more >
LINQ support
GraphQL server offers an ability to apply that information in form of LINQ expression on top of an existing IQueryable<> collection. Such application...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found