DEV Community

Discussion on: Free workshop on .NET Core + GraphQL + Serverless

Collapse
 
pascalsenn profile image
PascalSenn

Hi Shaijut & Chris
So GraphQL is not directly converted to SQL. But we do have a couple feature in hotchocolate.io that enable you to do so

Given this Query type we generate all the nested types you need. By annotating with attributes you can add additional behaviour on top of it.

public class Query {
     [UsePaging]
     [UseSelection]
     [UseSorting]
     [UseFiltering]
     public IQueryable<Jedi> GetJedis([Service]DBContext ctx) 
       => ctx.Jedis.AsQueryable()

}

When you now execute this query

{
  jedis(where: {name: "Han"}, order_by:{side:DESC}) { name side }
}

This SQL statement is executed:

SELECT [p].[Name],[p].[Side]
FROM [Jedis] AS [p]
WHERE [p].[Name] ="Han"
ORDER BY [p].[Side] DESC
Thread Thread
 
shaijut profile image
Shaiju T

Hi 😄 , What is difference b/w GraphQL for .NET and hotchocolate.io ? Why I should I use hotchocolate.io ? Anything special ?

Thread Thread
 
pascalsenn profile image
PascalSenn

Very good question :)
I think HotChocolate provides you with more features and more innovation. Code looks cleaner and it is overall much more fun to work with.
This question as asked in a issue once. You can read more about it here:
github.com/ChilliCream/hotchocolat...

This is a really good blog post about HotChocolate.
It only shows a fraction of it tough :D
dev.to/michaelstaib/get-started-wi...

Check out this example project If you want to get a feeling for it

Also, just join the community and try it out :)
You can find us on if you have any question along the way SLACK