Batching requests to subgraphs in GraphQL API federation setting

@Andrey_Nado @benassi the fix David mentioned was included in the latest release 4.3.0 that was just made available yesterday. If you’re still interested in it please switch to the newest version.

1 Like

Hi @agata-wit

I just checked version 4.3 and it works well, the requests to the secondary API provider are batched properly.

Thank you for the notification.

2 Likes

Hi @agata-wit what about doing the _entities query for 2 different entity?
I tried this and see tyk doint 2 roundtrip query, is this behavior expected?

Product Subgraph

type Product @key(fields: "id") {
    id: ID!
    name: String!
    variant: ProductVariant! 
}


type ProductVariant @key(fields: "id"){
  id: ID!
  name: String!
} 

Cart Subgrapah

type CartItem @key(fields: "id") {
    id: ID!
    qty: String!
    notes: String!
    product: Product!
}

extend type Product @key(fields: "id") {
    id:ID! @external
    variant: ProductVariant! @external
}

extend type ProductVariant @key(fields: "id"){
    id: ID! @external
}

I think it should be able to be batched into one query


query resolveEntity($representations: [_Any!]!) {
  _entities(representations: $representations) {
    ... on Product {
      id
      name
      category
    }
    ... on ProductVariant{
      id
      name
    }
  }
}

{
  "representations": [
    {
      "id": "productid1",
      "__typename": "Product"
    },
    {
      "id": "productid2",
      "__typename": "Product"
    },
    {
      "id": "variantid1",
      "__typename": "ProductVariant"
    },
    {
      "id": "variantid4",
      "__typename": "ProductVariant"
    }
  ]