Skip to content Skip to footer

How to implement GraphQL in ASP.Net Core Web API (.NET 6) using HotChocolate

2 Comments

  • Honza
    Posted 10. February 2022 at 00:28

    Looks nice, but this basically binds served GrapGl model data to the database model. When database changes, the GraphQl changes alongside with it. That is not acceptable for public facing API, slightly problematic when frontend and backend are developed by different teams.

    How do you deal with stable API requirement with changing database? Views in database mapped to EF are one option, but not one I would choose.

    • Post Author
      Christian Schou
      Posted 10. February 2022 at 09:23

      Hi Honza

      Thank you! It’s correct that the entities in the API would be affected if you changed the model in the application for the database and made a migration. If you run this in production you would end up with an angry front-end team for sure!

      A way to solve it would be using AutoMapper to map the models to a DTO. This would also allow you not to expose all of your model to the public. I will add it to my list of tutorials to make in the future.

Leave a comment

0/100