garlic/graphql
GraphQL Bundle 用于通过 Garlic 消息总线在微服务之间发送和接收 GraphQL 查询。
1.4.3
2019-12-23 10:11 UTC
Requires
- php: >=7.1
- symfony/maker-bundle: ^1.12
- symfony/orm-pack: ^1.0
- symfony/validator: ^4.2
- youshido/graphql-bundle: ^1.4
- dev-master
- 1.4.3
- 1.4.2
- 1.4.1
- 1.3.11
- 1.3.10
- 1.3.9
- 1.3.8
- 1.3.7
- 1.3.6
- 1.3.5
- 1.3.4
- 1.3.3
- 1.3.2
- 1.3.1
- 1.2.2
- 1.2.1
- 1.1.6
- 1.1.5
- 1.1.4
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- dev-feature/object_hydrator
- dev-feature/arg_helper
- dev-feature/fix-validator-version
- dev-generator-usefull-updates
- dev-add_list_type
- dev-feature/argument-filter
- dev-add_validation_add_errors
- dev-feature/unset-fix
- dev-fix_required_with_group
- dev-add_arguments_to_builder
- dev-list_type_issue
- dev-feature/readme-fix
This package is not auto-updated.
Last update: 2024-09-24 08:33:01 UTC
README
此包允许微服务通过 GraphQL 互相通信。应在两端正确安装以实现消息编码/解码流程。
此包基于 youshido-php/GraphQLBundle,因此特别感谢这些人的出色工作!我们只是做了一些更新;)
配置
使此包工作所需的必要事项
将包添加到 Symfony 项目中
composer require garlic/graphql
初始化 GraphQL 模式(创建模式、查询和突变字段)
bin/console make:graphql:init
创建 GraphQL 类型(可通过命令从现有实体获取字段)
bin/console make:graphql:type
命令建议您创建完整的 CRUD 突变和查询,只需输入 "y" 即可。将创建具有相关功能的 CRUD 类。要使此包工作,您需要最后更新 service.yaml
# Make graphql services public App\Service\GraphQL\: resource: '../src/Service/GraphQL/*' public: true
创建您的第一个 GraphQL 查询或突变
bin/console make:graphql:query
现在您可以审查和更新新创建的文件!
是时候运行您的第一个查询了!尝试将查询发送到 mydomain.com/graphql
用法
使用包后的示例步骤
- 创建实体(例如公寓)
- 使用上面的命令创建 GraphQL 类型(例如命名为 Apartment),输入 "y" 以自动创建 CRUD 突变。
- 尝试执行查询
{
ApartmentFind(id:1){
id
}
}
使用相关类型
- 让我们创建一个新的实体(例如地址)并将其通过多对一关系连接到公寓。
- 类似步骤一创建 GraphQL 类型 "Address"
- 将新创建的类型添加到 Apartment 类型中,例如
new Address()
- 尝试查找具有地址字段的公寓(例如 id)
{
ApartmentFind(id:1){
id
address {
id
}
}
}
或直接通过 Address "where" 查询(例如 id)
{
ApartmentFind(address:{id:1}){
id
address {
id
}
}
}
GraphiQL 扩展
您可以在集成的模式、查询和突变文档的交互式编辑器中编写查询。要运行此编辑器,只需运行 graphiql 扩展。输入访问扩展 - mydomain.com/graphql/explorer 扩展仅在 Symfony 应用的开发模式下可访问。