I created a GraphQL endpoint based on the following article: http://lifeinide.com/post/2019-04-15-micronaut-graphql-with-transaction-and-security-support/
It works properly in my local machine, but not after deploy to AWS lambda by referring to https://github.com/micronaut-projects/micronaut-aws/tree/master/examples/api-gateway-example.
I tested the /ping API of the Lambda with postman, it is working perfectly. However, when I post a graphql query to /graphql end point, it always return "415 Unsupported Media Type".
I think something is missing, but I not sure what is it, appreciate if anyone here could point me a way on how to make it works.
Thank you.
After digging my head into source code, I found that graphQL post endpoint has Consumes property set to ALL i.e, / to accept any content type but in code they are specifically referring to application/json or application/graphQL.
When you hit the graphQL post endpoint with application/json then MICRONAUT lambda handler matches the content type with ALL, which is not true so it throws error 415 Unsupported Media Type. Request never reaches to the graphQL controller.
When you hit the graphQL post endpoint with / then MICRONAUT lambda handler matches the content type with ALL, which is seems to be true so it forward the request to GraphQL controller but in code it specifically looks for those specific content types. Again it relies on .equals method for comparison. Again it does not matches so throws 422 unprocessable entity.
I am still looking for solution to this.