Gato GraphQL is a WordPress plugin that provides a GraphQL server for WordPress. It allows to query, transform, and mutate any piece of data from the WordPress site, via GraphQL queries. It supports to integrate any 3rd-party WordPress plugin, adding fields and mutations to the GraphQL schema to query its data.
- Monorepo hosting multiple WordPress plugins:
- Gato GraphQL
- Gato GraphQL integrations
- Testing utilities
- Each plugin is composed of Composer packages, hosted in the same monorepo
- All plugins/packages are grouped into "layers"
- Dependency graph across layers:
submodules/ExtensionStarter/assets/img/dependency-graph.svg
- Plugins:
submodules/ExtensionStarter/layers/{layer_name}/plugins/{plugin_name} - Plugin packages:
submodules/ExtensionStarter/layers/{layer_name}/packages/{package_name} - Testing plugins:
submodules/ExtensionStarter/layers/{layer_name}/phpunit-plugins/{plugin_name} - Testing plugin packages:
submodules/ExtensionStarter/layers/{layer_name}/phpunit-packages/{package_name}
- Integrations stubs:
stubs/wpackagist-plugin/{integration-plugin}/stubs.php
- Configuration to generate plugins:
src/Config/Symplify/MonorepoBuilder/DataSources/PluginDataSource.php - Configuration to generate root
composer.json:src/Config/Symplify/MonorepoBuilder/DataSources/DataToAppendAndRemoveDataSource.php - VSCode mappings:
.vscode/launch.json - Lando webserver config to override volumes (point to local source):
webservers/gatographql-extensions/.lando.upstream.yml
- Downgrade source code
- Config file:
config/rector/plugins/{integration-plugin}/ - Source code:
src/Config/Rector/Downgrade/Configurators/Plugins/{Integration-plugin}ContainerConfigurationService.php
- Config file:
- Folder:
submodules/ExtensionStarter/layers/GatoGraphQLForWP/plugins/gatographql/ - Main file:
gatographql.php
- Source code:
src/ - Main file:
Module.php - Unit Tests:
tests/Unit/ - Symfony DependencyInjection configuration:
config/- GraphQL schema services:
schema-services.yaml - All other services:
services.yaml
- GraphQL schema services:
- Conditional logic (if another package is installed):
src/ConditionalOnModule/{depended_package_name}
- Main file:
gatographql-{plugin_name}.php - Integration Tests:
tests/Integration/ - Module Resolvers:
src/ModuleResolvers/ - Symfony DependencyInjection configuration for Module services:
config/module-services.yaml - Module documentation:
docs/modules/
- Object Type Resolvers:
src/TypeResolvers/ObjectType/ - Custom Scalar Resolvers:
src/TypeResolvers/ScalarType/ - Enum Resolvers:
src/TypeResolvers/EnumType/ - Interface Resolvers:
src/TypeResolvers/InterfaceType/ - Input Object Resolvers:
src/TypeResolvers/InputObjectType/ - Union Type Resolvers:
src/TypeResolvers/UnionType/ - Resolvers to add Object Types to Union Types:
src/ObjectTypeResolverPickers/ - Object Field Resolvers:
src/FieldResolvers/ObjectType/ - Interface Field Resolvers:
src/FieldResolvers/InterfaceType/ - Mutation Resolvers:
src/MutationResolvers/ - DataLoader Resolvers:
src/RelationalTypeDataLoaders/ - Directive Resolvers:
src/DirectiveResolvers/
- Based on fixtures, containing:
- A GraphQL query to execute against the GraphQL server
- A dictionary of GraphQL variables, as a
.var.jsonfile (Optional) - The expected response in JSON
- Follow Coding Standards as defined in
.cursor/rules/php-wordpress.mdc - Dependency injection via Symfony DependencyInjection
- PHPStan for static analysis
- PHPCS for code style enforcement
- Use type hints and PHPDoc blocks for all new code
- Maintain PHPStan baseline in
phpstan-baseline.neon - Maintain PHPCS baseline in
phpcs.baseline.xml
- Branch naming:
feature/,fix/,enhancement/prefixes - Commit messages should reference ticket numbers when applicable
- Keep commits atomic and focused
- PHPUnit for unit testing
- PHPUnit with Lando for integration tests
- Test new plugin integrations thoroughly
- Test against supported WordPress versions (latest - 2)
- Test against supported WooCommerce versions when applicable
- Always check existing integration patterns before creating new ones
- Prioritize maintaining backward compatibility
- Follow established hook naming conventions
- Use existing helper functions and utilities
- Reference services from the container
When asking AI to generate code:
- Interacting with Services
// Define the service in the class
private ?{ServiceInterface} ${service} = null;
final protected function get{Service}(): {ServiceInterface}
{
if ($this->{service} === null) {
/** @var {ServiceInterface} */
${service} = $this->instanceManager->getInstance({ServiceInterface}::class);
$this->{service} = ${service};
}
return $this->{service};
}
// Use service
${service} = $this->get{Service}();
${service}->doSomething();- Creating schema-services.yaml
services:
_defaults:
public: true
autowire: true
# Service definitions...
- Creating services.yaml
services:
_defaults:
public: true
autowire: true
autoconfigure: true
# Service definitions...
- Execute
composer update-monorepoto regeneratecomposer.jsonat the monorepo root - Add the new package to the VSCode mapping
- Add the new package to the Lando webserver config
- Plan and propose: Given the requirements, check for similar packages already included in Gato GraphQL
- Create folders, files, and code for the packages
- Implement the logic
- Follow all the steps from common task "Updating monorepo config for new package"
- Follow all the steps from common task "Creating a package in Gato GraphQL"
- Add a new module for Gato GraphQL
- Add the module documentation
- Create integration tests
- Execute
composer init-serverto start the Lando webserver
- Plan and propose: Given the requirements, check for a similar plugin in the monorepo, and propose how to create the new integration, and how it will extend the GraphQL schema
- Create folders, files, and code for plugin and packages for the integration
- Execute
composer require --dev "wpackagist-plugin/{plugin}"to add the 3rd-party plugin incomposer.json - Execute
composer update-monorepoto regeneratecomposer.json - Add the new plugin and packages to the VSCode mapping
- Add the new plugin and packages to the Lando webserver config
- Update the configuration in
PluginDataSourceto generate the new plugin - Update the configuration in
DataToAppendAndRemoveDataSourceto remove the 3rd-party plugin fromrequire-dev - Implement the logic to extend the GraphQL schema for the integration
- Add a new module for Gato GraphQL
- Add the module documentation
- Create integration tests
- Execute
composer init-serverto start the Lando webserver
- Sanitize all inputs
- Validate API responses
- Use nonces for admin actions
- Follow WordPress security best practices
- Never store sensitive data unencrypted
- Use PHPDoc blocks for classes and methods
- Document filter/action hooks
- Explain complex logic
- Mark deprecated functions
type(scope): description
[optional body]
[optional footer]
- Description of changes
- Testing instructions
- Screenshots if UI changes
- Related issues/tickets
-
Analysis Phase
- Review existing code patterns
- Check integration examples
- Verify dependencies
- Initialize/update
.cursor/scratchpad.mdwith task details
-
Scratchpad Management
- Location: Always use
.cursor/scratchpad.md - Format:
current_task: "Task description" status: in_progress|complete|blocked steps: [ ] Step 1 [X] Completed step reflections: - Key learnings - Potential improvements - Technical considerations - Update status and steps as work progresses
- Document blockers and solutions
- Track important decisions
- Location: Always use
-
Implementation Phase
- Generate code following standards
- Add proper error handling
- Include logging statements
- Add type hints and documentation
-
Review Phase
- Code style compliance
- Security review
- Documentation completeness
- Performance optimization
-
API Issues
- Check API credentials
- Verify endpoint URLs
- Review rate limits
- Check for SSL issues
-
Integration Problems
- Verify plugin compatibility
- Check hook priorities
- Review field mappings
- Check for conflicts
-
Performance Issues
- Review query optimization
- Check caching implementation
- Verify async operations
- Monitor memory usage
readme.txt- Plugin documentation