DEV Community

Randel Ramirez
Randel Ramirez

Posted on

ASP.NET Core (Rest Web API or GraphQL)

I'll be working on a new pet project, the project consists of client applications(Web Application SPA, and a Xamarin.Forms mobile Application), the backend will be ASP.NET Core, now I'm curious if I should use Web API(Rest) or should I go use GraphQL?

Another question also, is GraphQL the new way to go when implementing APIs which is going to be consumed by different client apps(mobile and web)?

Top comments (4)

Collapse
 
theonlybeardedbeast profile image
TheOnlyBeardedBeast • Edited

I suggest GraphQL even if it is challenging at first, it is really nice for code-first usage. Maybe take a look at hotchocolate.io/ it looks easier than graphql-dotnet.github.io/ , also you can find GraphQL voyager and playground on NuGet, if you need those tools. But if you need any authorization/authentication you will need to implement it manually for GraphQL. Maybe take look on OData, it gives you the power of selectable response (even with including/joins and aggregations, filtering...) payload while maintaining everything as REST.

Collapse
 
randelramirez profile image
Randel Ramirez

Thanks! I’ll definitely check those links/resources you provided. I have tried OData in the past for some simple applicatiosn(POC type of app), I haven’t really tried GraphQL, I noticed APIs written in it are becoming more and more prevalent. Interesting that you mentioned OData, so does it mean we can use OData with Rest we’ll get the benefits of GraphQL without using it? 😅

Collapse
 
theonlybeardedbeast profile image
TheOnlyBeardedBeast • Edited

Definitely some of them, even more, if you don't like to write aggregations filtering or sorting because with OData you can do it in a query. But evaluate the decision, I don't know how is OData support for .net Core 3.0,3.1 at this point, a couple of months ago it wasn't, and in December it was in beta. Everything has pros and cons. Choose what can help you the most. Anyway, I like to use Both. Good luck.

Thread Thread
 
randelramirez profile image
Randel Ramirez

I'll definitely have a look at both and see for myself the pros and cons, Thanks! 🙌