Unable to use Resolver Policy in a Graphql Resolver for POST http calls

Freddy Martinez Garcia 0 Reputation points

Hi guys

I have an API Management service with a Synthetic Graphql API. There, I'm trying to configure my mutations. Resolvers for this mutations are implemented in Azure Functions with the HttpTrigger, meaning that we need to call them by a HTTP call.

We tried with a GET method it works perfect, but we don't like the idea of calling our mutations by a GET request, we want to use a POST request.

My graphql schema looks like this:

schema {
  query: Query
  mutation: Mutation

type Mutation {  
	SendChatTextMessage(input: SendChatTextMessageInput!): SendChatMessageResp

	GetUserChatMessages(userId: UUID!): [ChatTextMessage]
input SendChatTextMessageInput {  
	messageId: UUID!  
	senderUserId: UUID!  
	receiverUserId: UUID!  
	messageContent: String!
enum Language {  
enum ChatMessageSendStatus {  
type ChatMessageErrorData {  
	code: Int  
	message: String
type SendChatMessageResp {  
	messageId: UUID!  
	status: ChatMessageSendStatus!  
	error: ChatMessageErrorData
type ChatTextMessage {  
	messageId: UUID!  
	senderUserId: UUID!  
	receiverUserId: UUID!  
	messageContent: String!

and I defined my Resolber policy like this:

        <set-url> [My Azure Function URL] </set-url>
        <set-header name="Content-Type" exists-action="override">
            var args = context.Request.Body.As<JObject>(true)["arguments"];  
            JObject jsonObject = new JObject
                new JProperty("input",
                    new JObject
                        new JProperty("messageId", args["input"]["messageId"]),
                        new JProperty("senderUserId", args["input"]["senderUserId"]),
                        new JProperty("receiverUserId", args["input"]["receiverUserId"]),
                        new JProperty("messageContent", args["input"]["messageContent"])
            return jsonObject.ToString();

when I try to run my mutation, I get the error: Could not test the resolver policy. Please try again later.

Can someone tell me if you have done this before? Cause in this post I saw that it's a known issue from 2022, but I'm not sure if this has been fixed by Microsoft or not.

Any help here please?

Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
1,940 questions
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,644 questions
{count} votes

1 answer

Sort by: Most helpful
  1. JananiRamesh-MSFT 23,566 Reputation points

    @Freddy Martinez Garcia Thanks for reaching out. As per the investigation we identified below two issues.

    1. HTTP resolver with set-body - Request set-body policy not invoked in http-data-source. It does affect the same scenario that the older issue was describing in this pos, so it is a regression. That is, the old issue was fixed, however the functionality there regressed in a different manner, due to another bug.
    2. Resolver testing UI - Fails with Internal Server Error when using generic notation (eg. As<JObject>()) in set-body

    Our product team is working on the fix, No ETA available as of now. Would recommend you track update in https://github.com/Azure/API-Management/releases.

    We apologize for the inconvenience caused by the issue. Feel free to add a comment if any questions.

    Please 'Accept as answer' and ‘Upvote’ if it helped so that it can help others in the community looking for help on similar topics.