Skip to content

Conversation

@devin-ai-integration
Copy link

📝 Description

This PR extends the existing shared types mechanism in the GraphQL client generator to include response types, addressing duplication of identical response types across different operations.

Key Changes:

  • Added responseTypeSignatures cache to track response types across all operations
  • Implemented structural signature comparison for response types based on property names and types
  • Added logic to move truly shared response types to a common .responses package
  • Preserves existing behavior for non-shared response types in operation-specific packages

How it works:

  1. During generation, collects all response types from each operation with their structural signatures
  2. After processing all operations, identifies response types that appear multiple times with identical structure
  3. Moves only the shared response types to ${packageName}.responses package
  4. Maintains existing per-operation packages for non-shared types

Implementation Details:

  • Uses property names and types to generate structural signatures for comparison
  • Filters response types by excluding .inputs and .enums packages and including operation-specific packages
  • Rebuilds TypeSpecs when moving to shared packages to ensure proper package references

Testing:

  • All existing tests pass (27/27)
  • Code passes ktlint and detekt checks
  • No regressions in existing functionality

Areas for Review:

  • Structural signature generation logic - does it correctly identify truly identical types?
  • Cross-operation state management using class-level responseTypeSignatures map
  • Filtering logic for identifying response types vs other generated types
  • Package naming convention (.responses) and potential conflicts
  • TypeSpec rebuilding process and potential metadata loss

Link to Devin run: https://app.devin.ai/sessions/443221ec4fc34abdae8cd3bf80457725

Requested by: @akkp-windsurf

🔗 Related Issues

This implements Step 1 of extending the shared types mechanism as described in the task requirements - comparing response types structurally and sharing identical ones across operations.

- Add responseTypeSignatures cache to collect response types across operations
- Implement structural signature comparison for response types based on property names and types
- Move shared response types to .responses package when identical structures are found across operations
- Process shared response types after all operations are generated to identify cross-operation duplicates
- Maintain existing behavior for non-shared response types in operation-specific packages

Co-Authored-By: Arthur Poon <[email protected]>
@devin-ai-integration
Copy link
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Repository owner deleted a comment from devin-ai-integration bot Sep 24, 2025
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