I am using Angular + Core v7.0.0, and trying to supply an API. I need this API to read the Http Request Body. I tested it with a simple endpoint, but always get error.
Here is the test endpoint method:
public class TestAppService : AppServiceBase { public string ReceiveString([FromBody] string body) { return body; } }
I tested it on swager. Whatever the input string is, it always returns an 400 error:
{ "result": null, "targetUrl": null, "success": false, "error": { "code": 0, "message": "Your request is not valid!", "details": "The following errors were detected during validation.\r\n - Unexpected character encountered while parsing value: x. Path '', line 1, position 1.\r\n", "validationErrors": [ { "message": "Unexpected character encountered while parsing value: x. Path '', line 1, position 1.", "members": [ "" ] } ] }, "unAuthorizedRequest": false, "__abp": true }
What did I miss?
Thanks,
Thank you for clarifying!
Do you have road map to add Mutation feature on GraphQL template in the near future, or I need to work it by myself?
BTW, I also expect the filter, sort, and pagenation on query. I wonder if you will add them on?
Thanks,
Understand. Thank you!
Thank you! You actually answered my next question.
I wonder how the Startup pipeling routes the GraphQL request to be handled by GraphQL.Net, instead of MVC controller.
Let's say I have a controller by chance named "GraphqlController". When a request sent from client to endpoint http://company.com/graphql/, it should be routed to GraphqlController, Index() Action method, as MVC default route map on Startup pipeline. Now, Apollo-Client sends a GraphQL request to same endpoint. Does it conflict with the GraphqlController?
Thank you for your code example! It is very helpful. After comparing the 5 different implements, I am going to pick the Apollo Client as my solution. Here is one thing I am still unclear:
Apollo sends the request query to https://<base url>/graphql. How does the server ROUTE this request to "ReservationQuery" to resolve the query? (i.e. Which C# code lines involve this pipeline?)
Thanks,
Do you mean the "Playground"? That is not what I am asking. I like to know "how to send a request to /graphql endpoint from Angular UI."
I tried Core+Angular v6.9.1. Running GraphQL Playground is good. It is also good by postman. I wonder how to send a request to /graphql endpoint from Angular UI. I didn't find any despription in document. Is there an automation like running "nswag/refresh.bat"? Can you give me a hint by an example either automation or manually creating?
Thanks,
I missed "Yarn". Just tried again. It works now. Thank you!
Here are the errors on console, when page started:
HTML1300: Navigation occurred. localhost:45776 (1,1)
4CSS3121: The media query -ms-viewport has been deprecated.
SCRIPT5007: SCRIPT5007: Unable to set property 'defaultSourceName' of undefined or null reference localhost:45776 (461,9)
SCRIPT5007: SCRIPT5007: Unable to get property 'unspecifiedClockProvider' of undefined or null reference GetScripts (1306,5)
SCRIPT5009: SCRIPT5009: 'jQuery' is not defined frontend-metronic.min.js (1,1312)
SCRIPT5009: SCRIPT5009: '$' is not defined localhost:45776 (472,9)
SCRIPT5009: SCRIPT5009: 'jQuery' is not defined jquery.fancybox.pack.js (2,2)
SCRIPT5007: SCRIPT5007: Unable to get property 'fn' of undefined or null reference owl.carousel.js (1718,2)
SCRIPT5009: SCRIPT5009: '$' is not defined localhost:45776 (481,9)