Click here to Skip to main content
15,922,584 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
how can use graphql.net with asp.net core against real database?

What I have tried:

went through graphql documentation but no proper direction.
Posted
Updated 19-Mar-19 2:02am

1 solution

GraphQL is not about real database access, it is a specification concerned with communicating with an API and be definition it is data source agnostic. It is not is a "complete package" to set up a full web application.

On top of an existing MVC based API, it is simply another Controller and it backing service which connect to the existing Models. It would be up to you to define the relationship between the Graph query and it's associated Model.

Redgate has an article for setting up a project using GraphQL with a Net Core API base:
Getting Started with GraphQL in ASP.NET - Simple Talk[^]
I know it does not go over setting it up with a database but it does go over the underpinnings, you just need to add in your database and your desired method of talking to it; it could be through a framework (Entity, nHibernate) or just plain old ADO or OLE.

If you need something a little more, NReco has a package out that includes a database layer to use ADO connected databases.
NReco GraphQL API for SQL database (C#/.NET)[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900