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)
But when I test it, I have an INVALID_OPERATION
{
"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