Reorganize mutation requests and improve schema generation - #5
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
src/Requests/Pending/tosrc/Requests/Pending/Mutations/subdirectory for better organization.github/workflows/sync-schema.ymlto automatically sync Linear's GraphQL schema daily and on-demand, with automatic release tagging when schema changessrc/Exceptions/LinearRequestException.phpto provide better error reporting with support for GraphQL error detailsLinearConnector.phpto handle GraphQL errors and exceptions properlyGithubRepo2.phpandOrganizationInviteDetailsPayload.phpcontract#[WithCasts]attributes to multiple data classes for proper date/time handlingcomposer.jsondescription and.phpstorm.meta.phpfor better IDE supportNotable Implementation Details
PendingAirbyteIntegrationConnectMutationRequest.php) in a dedicatedMutationssubdirectoryLinearDatecast for consistent date handling across the packagehttps://claude.ai/code/session_01FBUiq2mGsbnYtodnRhNguM