Skip to content

Reorganize mutation requests and improve schema generation - #5

Merged
inxilpro merged 4 commits into
mainfrom
claude/graphql-php-ast-release-hdwrm8
Sep 5, 2026
Merged

inxilpro merged 4 commits into
mainfrom
claude/graphql-php-ast-release-hdwrm8

Conversation

@inxilpro

@inxilpro inxilpro commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR reorganizes the mutation request classes and improves the overall package structure for better maintainability. The changes include moving mutation request classes to a new directory structure, adding automated schema synchronization, and enhancing error handling.

Key Changes

  • Reorganized Mutation Requests: Moved all mutation request classes from src/Requests/Pending/ to src/Requests/Pending/Mutations/ subdirectory for better organization
  • Added Schema Sync Workflow: Implemented .github/workflows/sync-schema.yml to automatically sync Linear's GraphQL schema daily and on-demand, with automatic release tagging when schema changes
  • Enhanced Error Handling: Added src/Exceptions/LinearRequestException.php to provide better error reporting with support for GraphQL error details
  • Improved Documentation: Updated README.md with comprehensive information about the auto-generated nature of the package and setup instructions
  • Added .gitattributes: Configured to keep the distributed package small by excluding unnecessary files from distribution
  • Updated Connector: Enhanced LinearConnector.php to handle GraphQL errors and exceptions properly
  • Added New Data Classes: Introduced GithubRepo2.php and OrganizationInviteDetailsPayload.php contract
  • Updated Data Classes: Added #[WithCasts] attributes to multiple data classes for proper date/time handling
  • Improved CI/CD: Updated GitHub Actions workflows for better test coverage and code style checking
  • Updated Metadata: Enhanced composer.json description and .phpstorm.meta.php for better IDE support

Notable Implementation Details

  • The mutation requests are now organized by type (e.g., PendingAirbyteIntegrationConnectMutationRequest.php) in a dedicated Mutations subdirectory
  • The schema sync workflow uses concurrency controls to prevent race conditions and supports manual triggering with optional force release
  • Error handling now properly extracts and reports GraphQL-specific errors from Linear's API responses
  • Multiple data classes now properly cast date fields using LinearDate cast for consistent date handling across the package

https://claude.ai/code/session_01FBUiq2mGsbnYtodnRhNguM

inxilpro and others added 4 commits September 4, 2026 19:51
Getting this to a releasable state. The generator was sound, but the runtime
around it sent GraphQL that Linear could not accept for most argument types.

Query building:
  - Send typed arguments as GraphQL variables instead of writing them into the
    query string. Lists were serialized as objects, enums as objects rather
    than bare names, and dates as a dump of the DateTime internals.
  - Stop dropping false, 0 and '' from input objects.

Errors:
  - Linear reports GraphQL errors with a 200 status, so the connector now
    inspects the body and throws LinearRequestException.

Code generation:
  - Support GraphQL unions: each union becomes an interface its members
    implement, queries request inline fragments plus __typename, and responses
    resolve to the member that came back.
  - Rename types that differ only by case, since PHP class names do not. The
    schema has both GithubRepo and GitHubRepo.
  - Generate in dependency order, so classes exist before anything reads them.
  - Cast scalar list properties, which stopped hydrating in laravel-data 4.3.
  - Name input classes correctly rather than relying on php-cs-fixer to rename
    them to match their file.
  - Namespace pending requests by kind, matching the response namespaces.

Dependencies and CI:
  - PHP 8.2+, Laravel 11/12/13, laravel-data 4.11+. All three Laravel versions
    pass the suite.
  - Add a daily workflow that fetches the live schema, rebuilds, tests, commits
    and tags. Removed or narrowed types move the minor version; additions move
    the patch version.
  - Add .gitattributes so tests, workbench and the schema stay out of the
    distributed package.

Tests cover argument serialization, error handling, union resolution, the
schema round-trip and diff, and the integrity of the generated tree.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FBUiq2mGsbnYtodnRhNguM
GitHub had disabled .github/workflows/phpunit.yml for inactivity, so no tests
ran on pushes or pull requests. A scheduled workflow at a fresh path registers
as active again. The workflow name is unchanged, so the README badge still
resolves.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FBUiq2mGsbnYtodnRhNguM
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FBUiq2mGsbnYtodnRhNguM
The test workflow had not run since 2024, so two under-declared floors went
unnoticed:

  - orchestra/testbench below 9.2 sets a static $latestResponse property that
    nothing in its trait composition declares, which errors out every test.
  - saloonphp/saloon below 3.5 has no MockClient::destroyGlobal(), which the
    tests use to isolate the global mock client.

Verified against the real lowest resolution for Laravel 11: framework 11.11.0,
testbench 9.2.0, phpunit 10.5.1, saloon 3.5.0, graphql-php 15.10.0 and
php-parser 5.0.0 all pass, as does the highest.

Also pass --dev when installing testbench in CI, so it is not promoted into
the production requirements for the run.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FBUiq2mGsbnYtodnRhNguM
@inxilpro
inxilpro merged commit 465f265 into main Sep 5, 2026
34 checks passed
@inxilpro
inxilpro deleted the claude/graphql-php-ast-release-hdwrm8 branch September 5, 2026 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant