Skip to content

Latest commit

 

History

History
74 lines (56 loc) · 2.42 KB

File metadata and controls

74 lines (56 loc) · 2.42 KB

ProcessGraphQL Agent Guide

This document is for AI agents (and humans) working on the ProcessGraphQL codebase. It outlines the project structure, development workflows, and common tasks.

Project Overview

ProcessGraphQL is a ProcessWire module that seamlessly integrates GraphQL into a ProcessWire application. It allows users to serve a GraphQL API of their existing content without modifying structure.

  • Stack: PHP (ProcessWire), Node.js (Dev tooling).
  • Core Library: webonyx/graphql-php.
  • Key Features:
    • Schema generation based on ProcessWire Templates and Fields.
    • Access Control (respects ProcessWire permissions).
    • GraphiQL interface.
    • Extensible via Hooks (getQueryFields, getMutationFields).

Directory Structure

  • src/: Core PHP source code (PSR-4 ProcessWire\GraphQL\).
  • test/: PHPUnit tests.
  • ProcessGraphQL.module: Main module file (ProcessWire entry point).
  • ProcessGraphQLConfig.php: Module configuration logic.
  • graphiql/: GraphiQL interface assets.
  • vendor/: Composer dependencies.

Development Workflow

Prerequisites

  • PHP >= 7.4
  • Composer
  • Node.js & NPM

Setup

  1. Install dependencies:
    npm install
    # This automatically runs composer install via postinstall

Testing

  • Run all tests: npm test (Runs PHPUnit)
  • Performance tests: npm run test:performance
  • Coverage: npm run test:cover

Code Style

  • Prettier: npm run prettier (Formats code)

Common Tasks

1. Adding Support for a New Fieldtype

Check src/Type/Fieldtype/ to see existing implementations.

  • Create a new class mapping the ProcessWire Fieldtype to GraphQL types.
  • Register it in the main schema generation logic.

2. Debugging

  • Use test/client.php and test/server.php for local testing (via npm start).
  • Logs are typically handled by ProcessWire's logging system.

3. Release

  • Uses semantic-release.
  • Commit messages should follow conventional commits (e.g., feat:, fix:) to trigger version bumps.

Known Issues / Todo

See Todo.md for the current backlog.

  • N+1 Problems: Needs optimization for Files, Images, and Repeaters.
  • Security: Selector sanitization needs review.
  • Performance: Query complexity limiting is missing.

Useful Commands

  • composer dump-autoload: Regenerate autoloader after adding classes.
  • ls -F: Quick check of file structure.

Generated by Dobby (AI Agent)