wedrix/watchtower-bundle
Composer 安装命令:
composer require wedrix/watchtower-bundle
包简介
Symfony bundle for watchtower
README 文档
README
WedrixWatchtowerBundle integrates Watchtower with Symfony so you can expose a GraphQL API from Doctrine entities with minimal setup.
Requirements
- PHP
8.0+ - Symfony
5.4,6.4, or7.x wedrix/watchtower^10.0
Installation
-
Enable Symfony contrib recipes (once per project):
composer config extra.symfony.allow-contrib true -
Install the bundle:
composer require wedrix/watchtower-bundle -
Generate your initial schema:
php bin/console watchtower:schema:generate
Your GraphQL endpoint is served through the configured endpoint path (commonly /graphql.json).
When calling the endpoint from browsers, make sure CORS is configured if needed (for example with NelmioCorsBundle).
Quick Start
Run a query:
curl -X POST 'http://localhost:8000/graphql.json' \ -H 'Content-Type: application/json' \ -d '{"query":"{ __typename }"}'
The route accepts POST requests only.
Configuration
Configure the bundle in config/packages/wedrix_watchtower_bundle.yaml:
wedrix_watchtower_bundle: endpoint: '/graphql.json' schema_file: '%kernel.project_dir%/resources/graphql/schema.graphql' plugins_directory: '%kernel.project_dir%/resources/graphql/plugins' scalar_type_definitions_directory: '%kernel.project_dir%/resources/graphql/scalar_type_definitions' cache_directory: '%kernel.cache_dir%/watchtower' optimize: false debug: '%kernel.debug%' context: entity_manager: 'doctrine.orm.entity_manager'
Options:
endpoint: GraphQL endpoint path.schema_file: GraphQL schema file path.plugins_directory: directory containing Watchtower plugins.scalar_type_definitions_directory: directory containing scalar type definition files.cache_directory: directory used for Watchtower cache artifacts.optimize: enables cache-first execution mode; runwatchtower:cache:generateafter schema/plugin/scalar changes.debug: includes GraphQL debug details in responses.context: map of context keys to Symfony service IDs; resolved services are exposed to plugins viaNode::context().
At runtime, plugins also receive these built-in context entries:
request: currentSymfony\Component\HttpFoundation\Requestresponse: currentSymfony\Component\HttpFoundation\Response
Console Commands
watchtower:schema:generate: generate a new schema file from Doctrine metadata.watchtower:schema:update: currently invalidates schema cache; it does not rewrite the schema file yet.watchtower:cache:generate: generate cache files used by optimize mode.watchtower:plugins:add: generate plugin boilerplate interactively.watchtower:plugins:list: list configured plugins.watchtower:scalar-type-definitions:add: generate scalar type definition boilerplate.watchtower:scalar-type-definitions:list: list configured scalar type definitions.
watchtower:plugins:add supports:
constraintroot_constraintfilterorderingselectorresolverauthorizorroot_authorizormutationsubscription
For plugin conventions and feature details, see the upstream Watchtower docs:
- Plugins: https://github.com/Wedrix/watchtower#plugins
- Scalar types: https://github.com/Wedrix/watchtower#scalar-type-definitions
- Full feature docs: https://github.com/Wedrix/watchtower#features
Development
Run tests:
composer test
CI runs a dependency matrix across supported PHP, Symfony, and Doctrine ORM combinations (including lowest and latest lanes for key baselines).
统计信息
- 总下载量: 86
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-07-09