refactor: from manual type definitions to GraphQL codegen#42
Closed
iamfj wants to merge 31 commits intoczottmann:mainfrom
Closed
refactor: from manual type definitions to GraphQL codegen#42iamfj wants to merge 31 commits intoczottmann:mainfrom
iamfj wants to merge 31 commits intoczottmann:mainfrom
Conversation
Add type aliases for GraphQL query/mutation return types to improve readability in method signatures. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Return raw codegen types directly instead of transforming to manual types. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Return union type of raw codegen types instead of transforming. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Return raw codegen type directly. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Return raw codegen type directly. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Use QuerySearchIssuesArgs instead of full query type. Remove transformation. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Delete transformIssueData and doTransformIssueData - no longer needed since services return raw codegen types. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Pass QuerySearchIssuesArgs fields directly instead of wrong type. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Ensure parameters match IssueUpdateInput type from codegen. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Add type aliases, remove transformations, return raw GraphQL types. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Add type aliases, remove transformations, return raw GraphQL types. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Define CycleListOptions and CycleReadOptions locally. Replace LinearCycle with codegen type alias. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Add missing option interfaces (MilestoneListOptions, MilestoneReadOptions, MilestoneCreateOptions, MilestoneUpdateOptions) and replace LinearProjectMilestone with ProjectMilestoneUpdateInput from codegen. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Change the identifier used in the error message when an issue is not found during resolution from `id` to `resolvedIssueId` for improved clarity and accuracy.
Delete linear-types.d.ts - all types now generated from GraphQL schema via codegen. - Add type aliases in linear-service.ts for LinearLabel, LinearComment, and CreateCommentArgs - Replace LinearProject with inline type definition - Fix bug in graphql-issues-service.ts: use input.projectMilestoneId instead of input.milestoneId - Remove dead code for milestone fallback lookup Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Updated the GraphQL requests in the GraphQLIssuesService to enforce return types using codegen types. Added comments to clarify the importance of matching the return type with the appropriate GraphQL document.
Reformatted import statements for better readability and consistency. Aligned async calls for GraphQL requests to enhance code clarity. This change does not affect functionality but improves maintainability.
Updated the FileService class to utilize the generated FileUploadDocument for the GraphQL file upload mutation, enhancing type safety and maintainability. Removed the hardcoded mutation string in favor of the imported document.
Collaborator
Author
|
I started this work to introduce strict typing across the API. This alone fixed a few minor bugs and made the codebase feel much more robust. As I dug deeper, I noticed some overly complex architectures that I’d like to simplify. Since that’s out of scope here, I’ve started a v2 branch in my fork to address those issues and other requests from the community. My goal isn’t to create a competing CLI, but to build a clean, robust, and well-tested version that can be reintegrated into the original project. I appreciate the work @czottmann has done and have already reached out. I’ll keep you posted and will open a draft PR for v2 soon. Best, |
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.
Replaces manual TypeScript type definitions with automatically generated types from the Linear GraphQL schema using
@graphql-codegen. This migration eliminates ~330 lines of manually maintained type definitions and ensures our types stay in sync with the actual Linear API.Motivation
The Problem:
linear-types.d.ts) required constant maintenance as the Linear API evolvedThe Solution:
GraphQL Code Generator automatically creates TypeScript types directly from:
This means our types are always accurate and reflect exactly what the API returns for our specific queries.
Changes
Type System Migration
src/utils/linear-types.d.ts(330 lines of manual types)@graphql-codegen/client-presetgraphql-issues-service.ts- Added type aliases, removed transformation layergraphql-documents-service.ts- Migrated to codegen typesgraphql-attachments-service.ts- Migrated to codegen typeslinear-service.ts- Added type aliases for custom return shapesCommand Layer Updates
issues.ts- Fixed parameter types to match codegencycles.ts- Added missing option interfaces, use codegen typesproject-milestones.ts- Added option interfaces, use codegen typesArchitecture Improvements
IssueFromId | IssueFromIdentifier)Benefits
1. Type Safety
2. Maintainability
3. Developer Experience
4. Code Quality
JSON output should be identical to previous behavior.
Breaking Changes
None. This is a refactoring that maintains the same external API and JSON output structure.
Dependencies
Added:
@graphql-codegen/cli- Code generation tooling@graphql-codegen/client-preset- TypeScript type generation@graphql-codegen/introspection- Schema introspection@graphql-codegen/schema-ast- Schema AST utilitiesFuture Improvements
prestartscript (should benpm run generatenotgenerate).gitignoreif we want to generate on-demand