I am trying to create an angular project with .net core 2.1 with GraphQL library. I am totaly new in PostgresSQL, GraphQL & PostGraphile. So, just want to know is it possible to use PostGraphile with my angular .net core project. I have added a package for GraphQL but, didn't find the package for PostGraphile. Angular is not neccesary for me if I can create a project with react.net then it would be ok.
Asked
Active
Viewed 260 times
2 Answers
0
I am using postgraphile in my Asp.net project and I send HttpClient request to communication.
public class TestController : ControllerBase
{
private readonly IHttpClientFactory _httpClient;
public TestController(IHttpClientFactory httpClient)
{
_httpClient = httpClient;
}
[HttpPost("get-all")]
public async Task<YourViewModel> GetAll([FromBody] Input query)
{
var requestUri="http://localhost:5000/graphql"; //postgraphile Ip address
var content = new StringContent(query.Query, Encoding.UTF8, "application/graphql");
var response = await _httpClient.CreateClient().PostAsync(requestUri, content);
string resultContent = await response.Content.ReadAsStringAsync();
return JsonConvert.DeserializeObject<YourViewModel>(resultContent);
}
}
public class Input
{
public string Query { get; set; }
}

Mohammad Almasi
- 400
- 6
- 19