hotchoc calling API endpoint - working sample

 

Here is a working sample for hotchoc graphql calling an endpoint. The sample code can be found here

https://github.com/mitzenjeremywoo/graphql-api-integration


To get started install swag tool 

dotnet new tool-manifest

To install nswag console cli tool into your local project 

dotnet tool install NSwag.ConsoleCore --version 13.10.9

Generate the swagger.json from your API endpoint. This file will be used for code generation later

curl -o swagger.json http://localhost:5000/swagger/v1/swagger.json

Next, generate your client API that will be consuming or calling your API

dotnet nswag swagger2csclient /input:swagger.json /classname:TodoService /namespace:TodoReader /output:TodoService.cs

And finally add newtonsoft.json library 

dotnet add package Newtonsoft.Json

The step above is for generating the client. 

Integrate this client into your application code by following the code github code example. 

 You should be able to use Banana Cake Pop to run some graphql query against API. 






Comments

Popular posts from this blog

The specified initialization vector (IV) does not match the block size for this algorithm