When you install the package you'll get it as a dependency as well as everything you need to hook in into ASP.NET Core. Which is available as open source thanks to Joe McBride and all contributors. The one most commonly used is simply called GraphQL. Since GraphQL support is not provided within ASP.NET Core, you need a Nuget package. However when you use HTTP because now each piece of data is not at a unique URL anymore a downside of GraphQL could be that it's now difficult to do HTTP caching. HTTP is just a transport used to get the query to the API. HTTP is used most of the time in practice, especially with ASP.NET Core of course, but GraphQL doesn't need HTTP to function. In fact the GraphQL specification doesn't tie you to HTTP. Not the HTTP method and URI determine what should happen in the API but the query. The API reacts to GET or POST requests and whether GET or POST is used there is always a query contained in the request. So we're ending up with an ASP.NET Core API without any controllers. And because there has to be only one controller with a standard implementation to process GraphQL queries we can easily replace the controller with middleware. The schema also knows how to get that data using entity framework in this case.Īlso instead of multiple controllers there is now just one controller that reacts to GraphQL requests. This schema declares what data a consumer of the API can access. With GraphQL there are typically no models. In a REST API you typically work with models that represent the data. When the runtime has processed the query it typically returns JSON, but that is not set in stone by the specification. Part two is a runtime on the API that is able to process the query. Part one what GraphQL specifies is the format and syntax of the query. In this pic there is a consumer of the API that can be any kind of application. GraphQL is an open source specification created by Facebook that can be used to access data in APIs.
0 Comments
Leave a Reply. |