Laravel 联邦

Laravel Federation

我对 GraphQL 有疑问,我想与 Laravel 9 创建一个联盟。我使用:https://lighthouse-php.com/5/federation/getting-started.html 创建 monolog GraphQL 并创建了 2 个 Laravel 名为“a”和“b”的项目。他们分开工作很好。 “a”项目有一个人 table 具有 schema(id, name),第二个项目有一个 post table 具有 schema(id, text,person_id) 我想从具有 GraphQL 联合的“a”项目中获得 person_id。 当我用其他语言搜索联邦时,我发现了这个 link:https://www.apollographql.com/docs/federation/federation-spec/#type-_service 我将它定义到我的架构中,但它告诉我没有任何 @key-@extends-@external,... 指令。我使用 Laravel 命令创建了一个指令:“PHP artisan lighthouse: directive --argument Key” 我还为“extend”和“external”创建了它,但我不知道该怎么做在@key resolver 和@extends 以及@external 指令中写下我的代码。谁能帮帮我?

启用联邦后,必要的指令在 Lighthouse 中可用,无需您定义它们。为了帮助自动完成并满足 IDE 插件,请使用 php artisan lighthouse:ide-helper - 参见 https://lighthouse-php.com/5/api-reference/commands.html#ide-helper