Apollo graphql接口typedef

我有apollo界面链接此:

interface PageLayout {
        _id: String!
        id: ID! @globalID
        title: String
        subtitle: String
        template: String! @default(value:"none")
        layout: String
        layoutMobile: String
        showCount: Float
        showCountMobile: Float
        imageHeight: Int
        cardDesign: String
        cardShadow: Int
    }

并具有实现接口的这种类型:

type PageLayoutBannerRow implements PageLayout {
        _id: String!
        id: ID! @globalID
        title: String
        subtitle: String
        template: String! @default(value:"none")
        layout: String
        layoutMobile: String
        showCount: Float
        showCountMobile: Float
        imageHeight: Int
        cardDesign: String
        cardShadow: Int

        banners: [PageLayoutBanner]! @default(value:[])
    }

对于每种类型,我都必须将所有Interface属性复制到我的类型中。

是否有解决方案来编写我的类型?

type PageLayoutBannerRow implements PageLayout {
        # not copy interface attributes

        banners: [PageLayoutBanner]! @default(value:[])
    }
zz19860418 回答:Apollo graphql接口typedef

不幸的是,它无法解决。有关更多详细信息,请参见文档https://graphql.org/learn/schema/#interfaces

根据您要实现的目标,您可能需要查看并集https://graphql.org/learn/schema/#union-types(但是从您的示例中看来,您肯定应该使用一个接口)。

本文链接:https://www.f2er.com/3159359.html

大家都在问