Giter VIP home page Giter VIP logo

Comments (3)

mkmarek avatar mkmarek commented on June 26, 2024

Hi, sure I can create an example during the upcoming weekend. I'll post a link here afterwards.

from graphql-dotnetcore.

bancroftway avatar bancroftway commented on June 26, 2024

+1 for this. Looking forward to the sample.

from graphql-dotnetcore.

mkmarek avatar mkmarek commented on June 26, 2024

Created a repo at https://github.com/mkmarek/graphql-dotnetcore-ef-example for now it contains just one query and one mutation but it should still explain one of the possibilities how to use it. I'll add more stuff and some furter explanation during the weekend hopefully. It went to be a little bit more difficult than I initially expected. But it's quite simmilar to a way how we use this library for real projects.

But basically it uses the CQRS pattern which I think works with GraphQL really well. For DB I used MSSQL but you can surely change that to whatever suits you. For the data access layer I picked unit of work pattern using https://github.com/arch/UnitOfWork library.

It also uses the ASP.NET core DI container quite heavily. You can notice that the graphql schema class doesn't really have anything. The flow is inverse. The types themselves are registering into the schema. The reason for that is here Another workaround would be of course possible if It managed those schema types outside the DI container.

I'm running quite old version of .NET core on my current laptop so you might have to upgrade the project.

To run it you need to:

  • change the connection string at appsettings.json
  • run the dotnet ef database update to populate your database
  • run it with dotnet run or through visual studio

Then if you go to http://localhost:yourport/public/index.html you should see the GraphiQL interface and there you can play around.

Enjoy!
Marek

from graphql-dotnetcore.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.