Federated Graphql in case of list of items

Federated Graphql in case of list of items


0

I have defined Subgraphs as below and data is fetched from multiple sources

Subgraph A

type Query {
getAllItems(type: String!) : AllItems
}

type AllItems{
  type: String
  response: QueryResponse
  items: [Item!]!
  pageInfo: Page
  totalCount: Int
}
type Item @key(fields: "id")  {
    val1: String
    val2: String
    id: ID! 

}

SubgraphB

type Item @key(fields: "id")  @extends {
    name: String!
    id: ID! @external

}

With this approach when getAllItems is called it fetches all items for given type and in subgraph B name is fetched for each item . It is kind of N+1 problem . What I want is

  1. Either fetch data from subgraphB with list of IDs
  2. Or I have kind of getAllitemsSubGraphB in SubgraphB but it might give slightly different set (with some extra items).So I want join on "id" field of SubgraphA so that non existing items from SubgraphA will be removed while giving response back
    How to achieve it


Load 3 more related questions


Show fewer related questions

0



Leave a Reply

Your email address will not be published. Required fields are marked *