liinkiing / graphql-maker-bundle
用于轻松为 Overblog GraphQLBundle 创建 GraphQL 类型的捆绑包
1.3.0
2020-04-27 14:13 UTC
Requires
- php: ^7.0.8
- overblog/graphql-bundle: ^0.11.0|^0.12.0|^0.13.0
- symfony/config: ^3.4|^4.0|^5.0
- symfony/console: ^3.4|^4.0|^5.0
- symfony/dependency-injection: ^3.4|^4.0|^5.0
- symfony/http-kernel: ^3.4|^4.0|^5.0
- symfony/maker-bundle: ^1.11.0
README
通过使用新的 Symfony Maker 组件,为 Overblog GraphQL Bundle 创建 GraphQL 类型,这是一个易于使用的捆绑包
安装
$ composer require liinkiing/graphql-maker-bundle
如果你使用 Symfony flex,它将自动在 bundles.php 文件中注册。否则,请手动注册捆绑包
// AppKernel.php class AppKernel extends Kernel { public function registerBundles() { $bundles = [ // ... new Liinkiing\GraphQLMakerBundle\GraphQLMakerBundle(), ]; // ... } }
配置
默认情况下,无需配置。它使用 约定优于配置,但如果你想要自定义行为,可以添加配置文件 config/packages/dev/graphql_maker.yaml
graphql_maker: root_namespace: App\GraphQL # Customize the root namespace where PHP mutations and resolver will be schemas: # You can also define, for any schemas if you use many, a custom out directory for types files public: out_dir: '%kernel.project_dir%/config/graphql/public/types' internal: out_dir: '%kernel.project_dir%/config/graphql/internal/types' preview: out_dir: '%kernel.project_dir%/config/graphql/preview/types'
使用方法
目前,你可以生成
- 类型
- 连接
- 查询
- 突变
$ bin/console make:graphql:type [--schema] $ bin/console make:graphql:connection [--schema] $ bin/console make:graphql:query [--schema] $ bin/console make:graphql:mutation [--schema] $ bin/console make:graphql:resolver
然后,你将需要回答一些问题来生成你请求的内容,就像 à la Maker