0

hope you are doing well ! I have been trying to write a GraphQL Mutation Resolver for a REST POST request in Azure APIM but nothing is working so far. The REST call takes an object with firstName, lastName, username, password and returns an object with the same fields.
Below is my current code. Any Help would be appreciated.

<set-graphql-resolver parent-type="Mutation" field="createUser">
  <http-data-source>
    <http-request>
      <set-method>POST</set-method>
      <set-url>[URL]</set-url>
      <set-header name="Content-Type" exists-action="override">
        <value>application/json</value>
      </set-header>
      <set-body>@{
        var args = context.Request.Body.As<JObject>(true)["arguments"];  
        JObject jsonObject = new JObject();
        jsonObject.Add("firstName", args["firstName"]);
        jsonObject.Add("lastName", args["lastName"]);
        jsonObject.Add("username", args["username"]);
        jsonObject.Add("password", args["password"]);
        return jsonObject.ToString();
      }</set-body>
    </http-request>
  </http-data-source>
</set-graphql-resolver>

UPDATE: This is the schema i am using: enter image description here

And this is how i am testing the mutation with the arguments and the original error i am getting: enter image description here

In Application insights, i am getting this error log: enter image description here

NOTE: This is the original response that i'm getting from a normal REST Request enter image description here

Thank you!

ElyAoun
  • 66
  • 4
  • What do you mean by it is not working? – Mo Haidar Oct 24 '22 at 12:48
  • @MohamadHaidar i'm always getting "internal server error" even though the original Rest call is working fine. – ElyAoun Oct 26 '22 at 11:30
  • It is hard to troubleshoot without seeing the synthetic GQL schema and collect OCP traces. if you can share those here, I can look at them. – Mo Haidar Oct 26 '22 at 13:48
  • @MohamadHaidar Hello, i updated my question and added all the details (The trace is big i can't upload it here, if you need a specific section of the trace let me know please so i can upload it). Let me know if you need anything else. Thank you for your time! – ElyAoun Oct 27 '22 at 06:24

1 Answers1

0

I contacted Microsoft about this issue and they told me that it is a bug on the service side. The product team is working on the fix and it will be released in v.33 (4 to 6 weeks).

ElyAoun
  • 66
  • 4