Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to resolve the abstract type "BrandBaseConfigVo" in GraphQL Mesh #5320

Closed
oaooao opened this issue Apr 10, 2023 · 1 comment
Closed

Comments

@oaooao
Copy link

oaooao commented Apr 10, 2023

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)

  1. Generate the provided schema using GraphQL Mesh.
  2. Execute the provided query using the generated schema.
  3. 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.

@ardatan
Copy link
Owner

ardatan commented Apr 29, 2024

Sorry for the late response! But we need a full reproduction with an example OpenAPI to reproduce it on our end.
If you still have the issue with the latest version, let us know so we can reopen this issue.

@ardatan ardatan closed this as completed Apr 29, 2024
This was referenced Apr 30, 2024
This was referenced May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants