wedrix / watchtower-bundle
Symfony bundle for watchtower
Installs: 86
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:symfony-bundle
pkg:composer/wedrix/watchtower-bundle
Requires
- php: ^8.0
- doctrine/doctrine-bundle: ^2.8
- symfony/framework-bundle: ^5.4 || ^6.4 || ^7.0
- symfony/yaml: ^5.4 || ^6.4 || ^7.0
- wedrix/watchtower: ^10.0
Requires (Dev)
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^9.6
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).