-
-
Notifications
You must be signed in to change notification settings - Fork 0
feat: implement queryOptions export pattern and type-safe query key builder #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Conversation
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
- 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>
4 tasks
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Collaborator
Author
|
Closing in favor of #27 which resolves the branch divergence. |
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
Key Improvements
useGetWidgets) (marked as deprecated) while adding new query/mutation options exports['gizmo', 'getGizmos', params || {}]Non-Breaking Changes
getGizmosQueryOptions()- for query operationscreateGizmoMutationOptions()- for mutation operationsgetGizmosInfiniteQueryOptions()- for paginated queriesinifinite→infinite)Technical Details
buildResourceKeymethod and URL path parsing logic, replaced with new query key structure['interface', 'method', params || {}]['interface', 'method', params || {}, {infinite: true}]Test plan
npm testto verify all tests passnpm run buildto ensure clean compilationnpm run lintto verify code stylesrc/snapshot/v1/🤖 Generated with Claude Code