Skip to content

Conversation

@kyleamazza
Copy link
Collaborator

@kyleamazza kyleamazza commented Jul 21, 2025

Summary

  • Implement queryOptions/mutationOptions export pattern for React Query v5 compatibility while maintaining backwards compatibility
  • Simplify query key structure to use interface/method naming pattern
  • Fix query key parameter syntax bug that was causing TypeScript errors

Key Improvements

  • Backwards Compatible: Preserves all existing hooks (e.g., useGetWidgets) (marked as deprecated) while adding new query/mutation options exports
  • Simplified Query Keys: Changed from URL-based resource keys to cleaner pattern: ['gizmo', 'getGizmos', params || {}]

Non-Breaking Changes

  • Added new exports alongside existing hooks:
    • getGizmosQueryOptions() - for query operations
    • createGizmoMutationOptions() - for mutation operations
    • getGizmosInfiniteQueryOptions() - for paginated queries
  • Fixed infinite query key typo (inifiniteinfinite)

Technical Details

  • Removed complex buildResourceKey method and URL path parsing logic, replaced with new query key structure
  • Query keys follow consistent structure:
    • Regular: ['interface', 'method', params || {}]
    • Infinite: ['interface', 'method', params || {}, {infinite: true}]
  • Updated build configuration to exclude snapshot directory from TypeScript compilation
  • Added README.md to .prettierignore to prevent formatting hangs

Test plan

  • Run npm test to verify all tests pass
  • Run npm run build to ensure clean compilation
  • Run npm run lint to verify code style
  • Review generated snapshots in src/snapshot/v1/
  • Verify backwards compatibility - all existing hooks remain functional
  • Test in a real project to confirm both old hooks and new options work correctly

🤖 Generated with Claude Code

kyleamazza-fq and others added 20 commits July 20, 2025 20:08
- Provides centralized naming logic for all generated names
- Includes methods for query options, mutation options, service names
- Maintains backward compatibility with existing hook names
- Move query hooks generation to generateLegacyQueryHooks
- Move mutation hooks generation to generateLegacyMutationHook
- Move infinite hooks generation to generateLegacyInfiniteHooks
- Clearly separate v0.2.0 features from v0.1.0 legacy code
- Prepare structure for adding new query options exports
- Export queryOptions functions for queries
- Export mutationOptions functions for mutations
- Export infiniteQueryOptions functions for paginated queries
- Use service getter functions instead of hooks
- Keep internal functions for backward compatibility
- Add non-hook service getter functions for query options
- Store context globally for access outside React components
- Update naming to use NameFactory for consistency
- Keep legacy hooks for backward compatibility
- Add JSDoc @deprecated tags to all legacy hooks
- Include migration examples showing new query options pattern
- Guide users to migrate to the new API
- Create QueryKeyBuilderFile for generating type-safe query keys
- Add matchQueryKey function with proper TypeScript overloads
- Include query-key-builder.ts in generated files
- Enable type-safe cache invalidation patterns
- Added helper functions to name-factory.ts for building consistent names
- Removed NameFactory class instantiation from HookFile
- Updated all v0.2.0 code sections to use helper functions instead of class methods
- Legacy v0.1.0 code remains unchanged
- This improves code clarity by using named functions that describe their purpose
…ents

- Remove buildDeprecationComment method and all its calls
- Update buildDescription calls to use isDeprecated parameter
- Simplifies generated code by using standard deprecation format
- Migration instructions removed but could be added to @basketry/typescript in future

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Create CHANGELOG.md following Keep a Changelog format
- Document new query options exports and deprecated hooks
- Fix package.json description to accurately describe the package

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Use bracket notation for all parameter access (uniform approach)
- Properly quote object keys in query key generation
- Fix syntax for optional chaining with bracket notation
- Ensures compatibility with parameter names containing hyphens or other special characters

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Fixed getHookName to properly generate suspense hook names for all methods
- Methods that don't start with 'get' now correctly get useSuspense prefix
- Resolves duplicate function declarations in generated code

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Update description to reflect React Query v5 queryOptions generation
- Add comprehensive Getting Started section with step-by-step setup
- Add configuration examples with anonymized, generic paths
- Document typesModule and clientModule configuration options
- Include examples for queries, mutations, and infinite queries
- Update provider example to use BasketryExampleProvider
- Improve overall documentation clarity for new users

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Replace NameFactory class with individual helper functions
- Add missing helper functions: buildContextName, buildProviderName, buildServiceName
- Update context-file.ts to use helper functions instead of class instance
- Rename name-factory.ts to name-helpers.ts to better reflect its purpose
- Remove CLAUDE.md from version control (added to .gitignore)

This completes the migration to v0.2.0 patterns using helper functions
instead of classes for better modularity and tree-shaking.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Replace URL-based resource keys with interface/method pattern
- Use camelCase for interface names in query keys (e.g., ['gizmo', 'getGizmos', params])
- Fix typo in infinite query keys (inifinite → infinite)
- Simplify mutation invalidation to invalidate by interface name
- Remove buildResourceKey method and related complexity

This aligns the query key generation with the export-query-options branch
implementation for consistency between legacy hooks and new queryOptions exports.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Fix incorrect 'params?' syntax in query keys (should be 'params || {}')
- Add README.md to .prettierignore to prevent formatting hangs
- Exclude snapshot directory from TypeScript compilation
- Update generated snapshots with corrected query key syntax

This fixes a TypeScript error where optional parameter syntax was incorrectly
included in runtime expressions.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
The 'q' variable was no longer needed after simplifying the query key generation.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Document query key improvements, bug fixes, and internal refactoring

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@kyleamazza kyleamazza marked this pull request as ready for review July 21, 2025 05:06
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
@kyleamazza
Copy link
Collaborator Author

Closing in favor of #27 which resolves the branch divergence.

@kyleamazza kyleamazza closed this Aug 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.

3 participants