Installation:
composer require dbp/relay-maker-bundle
Ensure the bundle is enabled in config/bundles.php:
return [
// ...
DigitalBlueprint\RelayMakerBundle\DbpRelayMakerBundle::class => ['all' => true],
];
First Use Case: Generate a Relay-compatible bundle with an example entity:
./bin/console dbp:relay:maker:make:bundle \
--vendor=YourVendor \
--unique-name=YourBundle \
--friendly-name="Your Bundle" \
--example-entity=User
This creates a bundles/YourBundle directory with:
YourBundle.php).User.php) with Relay annotations.services.yaml and config/ structure.Where to Look First:
./bin/console dbp:relay:maker:make:bundle --help to explore options.bundles/ for the new bundle’s structure.@RelayType and @RelayField in generated entities.Bundle Development:
Mutation or Query resolver by creating files in src/Resolver/ and referencing them in services.yaml.Entity Generation:
./bin/console dbp:relay:maker:make:entity User --fields="name:string,email:string!@unique"
string, id, boolean) and directives (@unique, @default).Integration with Relay:
schema.graphql file in the bundle’s Resources/ directory. Extend it by adding custom directives or types.services.yaml includes Relay-specific services (e.g., relay.resolver). Override defaults by extending the bundle’s configuration.Testing:
--dry-run flag to preview changes:
./bin/console dbp:relay:maker:make:bundle --dry-run --vendor=Test
config/bundles.php and running:
./bin/console debug:container | grep relay
Resources/skeleton/ directory in your project.--no-confirm for CI/CD pipelines:
./bin/console dbp:relay:maker:make:bundle --no-confirm --vendor=Acme --unique-name=AcmeRelayBundle
Namespace Conflicts:
--vendor and --unique-name match your project’s PSR-4 autoloading. Example:
./bin/console dbp:relay:maker:make:bundle --vendor=App --unique-name=AppRelayBundle
composer.json:
"autoload": {
"psr-4": {
"App\\": "src/",
"App\\Relay\\": "bundles/AppRelayBundle/src/"
}
}
Missing Dependencies:
digital-blueprint/relay and symfony/maker-bundle. Install them first:
composer require digital-blueprint/relay symfony/maker-bundle
Schema Merging:
schema.graphql files to avoid conflicts. Use tools like graphql-tools for validation.Entity Validation:
@RelayField for validation. Custom validation (e.g., @Assert\Email) requires manual addition to the entity class.Command Errors:
var/log/dev.log for maker-related issues.-v for verbose output:
./bin/console dbp:relay:maker:make:bundle -v
Generated Code:
git diff to inspect changes before confirming:
./bin/console dbp:relay:maker:make:bundle --dry-run | git diff
Custom Templates:
config/packages/dev/dbp_relay_maker.yaml:
dbp_relay_maker:
skeleton_dir: '%kernel.project_dir%/custom-skeletons'
Post-Generation Hooks:
Relay Configuration:
relay.yaml:
# config/packages/relay.yaml
relay:
schema:
query: App\\Relay\\Query\\CustomQuery
Field Directives:
RelayFieldType class or using PHP attributes:
use DigitalBlueprint\Relay\Attribute\RelayField;
#[RelayField(type: 'string', directives: ['@custom(detail="...")'])]
private string $customField;
```markdown
### Config Quirks
- **Bundle Registration**:
The maker auto-registers bundles in `config/bundles.php`, but manually verify the entry exists after generation.
- **Environment-Specific Config**:
The bundle generates `config/packages/dev/relay.yaml` and `prod/relay.yaml`. Override these for environment-specific settings (e.g., caching).
- **Symfony Maker Compatibility**:
Ensure `symfony/maker-bundle` is up-to-date to avoid template rendering issues. Run:
```bash
composer require symfony/maker-bundle:^1.0
How can I help you explore Laravel packages today?