Azure APIM GraphQL Union

Romain Pfund 0 Reputation points
2024-04-18T12:37:42.66+00:00

Hello,

I've found in the March release note (https://github.com/Azure/API-Management/releases/tag/release-service-2024-03)

and the documentation (https://learn.microsoft.com/en-us/azure/api-management/http-data-source-policy#resolver-for-graphql-union-type)

That we can start using GraphQL Union in APIM.

Based on the example, I've done a simple test GraphQL API but it doesnt't seems to work:

Here's my simple GraphQL Schema:

type Query {
  customerById(id: ID): Customer
}


union Customer = RegisteredCustomer | GuestCustomer

type RegisteredCustomer {
  customerId: Int!
  firstName: String
  lastName: String
  isActive: Boolean
}

type GuestCustomer {
  firstName: String
  lastName: String!
}

A simple resolver on the query, where I force the body response (when I test it I get the expected response, with the __typename from the doc)
resovler

But when I test it, I have an INVALID_OPERATION
test

{
  "errors": [
    {
      "message": "Error trying to resolve field 'customerById'.",
      "locations": [
        {
          "line": 2,
          "column": 2
        }
      ],
      "path": [
        "customerById"
      ],
      "extensions": {
        "code": "INVALID_OPERATION",
        "codes": [
          "INVALID_OPERATION"
        ]
      }
    }
  ],
  "data": {
    "customerById": null
  }
}

Am I doing something wrong or the Union is not available yet ?

Best regards

Romain

Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
1,845 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Romain Pfund 0 Reputation points
    2024-05-17T12:37:50.52+00:00

    Hi,
    Just needed to wait. Our APIM is now up to date and the Union example works.

    The May release Note https://github.com/Azure/API-Management/releases/tag/release-service-2024-05 announce the support on Interface, hope it will be available quickly.

    This thread can be considered close

    0 comments No comments