DEV Community

Discussion on: Learn how you can use GraphQL in .NET Core and C#

Collapse
 
softchris profile image
Chris Noring

is this for .NET or? you could be using this github.com/remorses/mongoke to expose your database as a GraphQL API or have a look here if you just want a tutorial on how to use it dev.to/alvarojsnish/graphql-mongod... . Let me know what you had in mind ? :)

Collapse
 
ronaldoperes profile image
Ronaldo Peres

Well,

I am thinking to use GraphQl with Dotnet Core, for example: if I have a collection in mongo of games - how to use GraphQl to retrieve data without doing a GetAll() in the collection?

Is there a way to setup the Mongodb repository in Dotnet core with GraphQl?

Thread Thread
 
softchris profile image
Chris Noring

Generally, you use a query that takes a parameter on the GraphQL side

// schema
{
  Query {
    GetCommentById(id: ID): Comment
  } 
}

// asking the query
query <name it something> {
  GetCommentById(id: 1)
}

As for dealing with .NET Core and MongoDB you have a tutorial here docs.microsoft.com/en-us/aspnet/co... . I suppose I could be writing a tutorial on GraphQL, .NET Core and MongoDB if you are interested?

Also have a look here dev.to/dotnet/how-you-can-build-a-... This shows how our request is passed from API to DB layer

Thread Thread
 
jghx profile image
jghx

I tried do to a combination of GraphQL, .NET Core and MongoDB but can seem te get the MongoDb working to you still need to use a DBContext and DBsets or can you just use IMongoCollection's like in the Microsoft tutorial?

Thread Thread
 
noamwe profile image
Noam Wertheim

Hi thank you for the links.
I would be very much interested in reading a tutorial on how to implement a GraphQl server with .NET Core and MongoDb.
So far only managed to implement it when all data sat in memory, which is of course not an acceptable solution.

Thread Thread
 
softchris profile image
Chris Noring

I'm looking into a GraphQL solution currently called Hot Chocolate. It has the concept of loaders. Yes some data need to sit in memory, but not all. Maybe that can offer a path forward? hotchocolate.io/docs/introduction....