axtiva / graphql-federation-extension
axtiva/flexible-graphql-php 扩展,支持 Apollo Federation 集成
v1.0.1
2022-04-05 00:02 UTC
Requires
- php: >=7.4
- webonyx/graphql-php: ^14.0
Requires (Dev)
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2024-09-05 05:21:03 UTC
README
库扩展 axtiva/flexible-graphql-php 或 webonyx/graphql-php 功能,使其作为 Apollo Federation 的子图服务
使用场景
- axtiva/flexible-graphql-bundle - 添加对 federation resolvers 的支持
配置
通过 composer 安装
composer require axtiva/graphql-federation-extension
演示集成
使用以下示例项目
演示联邦模式
如何查看目录 example
- 如何设置 Apollo 联邦模式请查看 example/extend_schema.php
在项目根目录下运行
php -S localhost:8080 ./example/extend_schema.php
现在您可以通过 https://:8080 发送 http graphql 请求
获取通用 graphql 请求
query{ account(id:234) { id number transactions { id amount } } }
获取联邦表示请求
query{ _entities(representations: [ {__typename: "Account", id: 123} {__typename: "Transaction", id: 333} ]) { __typename ...on Account { id number } ...on Transaction { id amount } } }
测试
运行测试
php vendor/bin/phpunit