在GraphQL中,您如何进行基本扩展类型?
发布时间:2020-12-15 09:36:54 所属栏目:百科 来源:网络整理
导读:例如,宠物是拥有所有者和名字的动物. type Animal { species: String}type Pet extends Animal { owner: Owner name: String} 解决方法 目前这在GraphQL中是不可能的,但是有一个实验包可能对此有用. https://github.com/Sydsvenskan/node-graphql-partials
例如,宠物是拥有所有者和名字的动物.
type Animal { species: String } type Pet extends Animal { owner: Owner name: String } 解决方法
目前这在GraphQL中是不可能的,但是有一个实验包可能对此有用.
https://github.com/Sydsvenskan/node-graphql-partials 见例子: partial LinkFields { links( rel: String type: String ): [Link] } partial DocumentFields using LinkFields { uuid: ID! # The document type,such as x-im/article type: String # If specified,then a list of the products to which this document's availability is limited products: [String] # The human readable name of the document,often used publicly to identify the document title: String # The specific path on the web page where this document is publicly available path: String # A single metadata block metaBlock( # The specific metadata block type to get type: String ): MetadataBlock } interface Document using DocumentFields {} type AuthorDocument implements Document using DocumentFields {} 结果如下: type AuthorDocument implements Document { links( rel: String type: String ): [Link] uuid: ID! # The document type,often used publicly to identify the document title: String # The specific path on the web page where this document is publicly available path: String # A single metadata block metaBlock( # The specific metadata block type to get type: String ): MetadataBlock } 您还可以做什么,因为这些只是字符串是创建一些帮助函数,修改字符串并插入必要的字段. 如果您在跟进Github上的讨论时遇到了异议,可以查看以下问题. https://github.com/graphql/graphql-js/issues/703 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |