<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>多态类型 on PlumePHP</title><link>https://plumephp.com/tags/%E5%A4%9A%E6%80%81%E7%B1%BB%E5%9E%8B/</link><description>Recent content in 多态类型 on PlumePHP</description><generator>Hugo</generator><language>zh-CN</language><lastBuildDate>Tue, 29 Sep 2026 13:00:00 +0800</lastBuildDate><atom:link href="https://plumephp.com/tags/%E5%A4%9A%E6%80%81%E7%B1%BB%E5%9E%8B/index.xml" rel="self" type="application/rss+xml"/><item><title>GraphQL 多态类型设计：Interface 与 Union 深度实践</title><link>https://plumephp.com/graphql-union-interface-design/</link><pubDate>Tue, 29 Sep 2026 13:00:00 +0800</pubDate><guid>https://plumephp.com/graphql-union-interface-design/</guid><description>&lt;p&gt;真实业务里，一个字段的返回值常常&amp;quot;是几种不同类型之一&amp;quot;：消息流里有文本、图片、视频消息；支付方式有卡、支付宝、钱包；内容平台有文章、视频、播客。GraphQL 用 &lt;strong&gt;Interface&lt;/strong&gt; 与 &lt;strong&gt;Union&lt;/strong&gt; 表达这种多态，但在设计上它们经常被误用——要么全部塞进一个&amp;quot;万能类型&amp;quot;，要么 interface 当 union 用、union 当 interface 用。设计对了，多态让 schema 表达力翻倍；设计错了，就是客户端噩梦。&lt;/p&gt;
&lt;p&gt;本文讲清 interface 与 union 的本质区别、多态 schema 建模、客户端消费模式、性能陷阱与演进策略。&lt;/p&gt;</description></item></channel></rss>