Description
Description
I am trying to use GraphQL Mesh to convert an existing RESTful API into a GraphQL schema(Simplified version). I have generated the following schema, but when I run the query provided below, I receive an error in the response.
Schema(Simplified version)
type Query
@globalOptions(
sourceName: "CDP"
endpoint: "{env.URL}/cdp-mgmt/v1/"
operationHeaders: "{\"Authorization_Header\":\"{context.headers.authorization}\",\"Authorization_Cookie\":\"Bearer {context.cookies.accessToken}\"}"
) {
brandConfig(
brandId: String!
type: String
): QueryCustomerConfigResponse
@httpOperation(
path: "/meta/{args.brandId}/config"
operationSpecificHeaders: "{\"accept\":\"application/json\"}"
httpMethod: GET
queryParamArgMap: "{\"type\":\"type\"}"
)
brandNotifyConfig(brandId: String!): QueryMetaCustomerConfigResponse
@httpOperation(
path: "/meta/{args.brandId}/notifyConfig"
operationSpecificHeaders: "{\"accept\":\"application/json\"}"
httpMethod: GET
)
dashboard(brandId: String!): QueryDashboardResponse
@httpOperation(
path: "/meta/config/dashboard/{args.brandId}"
operationSpecificHeaders: "{\"accept\":\"application/json\"}"
httpMethod: GET
)
}
type BrandConfigVo {
id: BigInt
brandId: String
brandBaseConfigVo: BrandBaseConfigVo
createTime: DateTime
createBy: String
updateTime: DateTime
updateBy: String
}
type QueryMetaCustomerConfigResponse {
responseCode: String
responseMsg: String
data: [BrandConfigVo]
}
type QueryCustomerConfigResponse {
responseCode: String
responseMsg: String
data: [BrandConfigVo]
}
enum query_queryDashboard_data_allOf_0_configType {
TAG_RULE
COHORT_RULE
CUSTOMER_LIST
CUSTOMER_VIEW
TAG_COHORT_LIST
TAG_NOTIFY_USER
TAG_CATEGORY_PERMISSION
COHORT_EXPORT
CUSTOMER_DASHBOARD
}
interface BrandBaseConfigVo @discriminator(propertyName: "configType") {
configType: query_queryDashboard_data_allOf_0_configType
}
type CustomerDashboardConfigVo implements BrandBaseConfigVo {
configType: query_queryDashboard_data_allOf_0_configType
allChannelCustomerConfig: AllChannelCustomerConfig
channelCustomerConfig: ChannelCustomerConfig
keyCohortConfig: KeyCohortConfig
tagConfig: TagConfig
cohortConfig: CohortConfig
}
type QueryDashboardResponse {
responseCode: String
responseMsg: String
data: CustomerDashboardConfigVo
}
Query
query Dashboard($brandId: String!) {
brandConfig(brandId: $brandId, type: "CUSTOMER_LIST") {
data {
brandBaseConfigVo {
configType
}
id
brandId
}
}
}
Error
{
"data": {
"brandConfig": {
"data": [
{
"brandBaseConfigVo": null,
"id": 31,
"brandId": "122"
}
]
}
},
"errors": [
{
"message": "Abstract type \"BrandBaseConfigVo\" must resolve to an Object type at runtime for field \"BrandConfigVo.brandBaseConfigVo\". Either the \"BrandBaseConfigVo\" type should provide a \"resolveType\" function or each possible type should provide an \"isTypeOf\" function.",
"path": [
"brandConfig",
"data",
0,
"brandBaseConfigVo"
]
}
]
}
Expected behavior
I expect the query to execute without any errors and return the requested data.
Steps to reproduce(Because it involves production projects and it is not convenient to provide reproducible examples, please refer to the following steps)
- Generate the provided schema using GraphQL Mesh.
- Execute the provided query using the generated schema.
- Observe the error in the response.
Possible solution
As the error suggests, the abstract type "BrandBaseConfigVo" must resolve to an Object type at runtime for the field "BrandConfigVo.brandBaseConfigVo". To fix this issue, either the "BrandBaseConfigVo" type should provide a "resolveType" function, or each possible type should provide an "isTypeOf" function.
Please let me know if you need any additional information or if there is a workaround available for this issue. Thank you for your assistance.