tailcallhq / tailcall

High Performance GraphQL Runtime
https://tailcall.run
Apache License 2.0
1.3k stars 254 forks source link

Support Concatenating Lists and Mapping Fields to GraphQL Union Types #3119

Open amitksingh1490 opened 1 week ago

amitksingh1490 commented 1 week ago

Description:

I have a use case involving two APIs, each returning lists in the following formats:

API 1 Response:

[
  { "id": 1, "username": "abc", "address": { "home": "123 st" } },
  { "id": 2, "username": "xyz", "address": { "home": "789 st" } }
]

API 2 Response:

[
  { "id": 3, "username": "pqr", "address": { "office": "123 st" } },
  { "id": 4, "username": "lmn", "address": { "office": "789 st" } }
]

I want to concatenate these lists into a single result while mapping the address field to a GraphQL union type defined as follows:


type User {
 id: ID!
 username: String
 address: Address
}

union Address = Home | Office

type Home {
  home: String
}

type Office {
  office: String
}

The system should support merging these lists and transforming the address field into the appropriate Home or Office type based on the input.

tusharmath commented 1 week ago

Should be solved using https://github.com/tailcallhq/tailcall/issues/3120