Open Paul-Hammer opened 1 month ago
The changes primarily focus on enhancing the src/introspection/utils.ts
file by introducing new generic types and refactoring existing functions for improved type mapping and code modularity. A new Mapper<T, R>
type is defined to standardize mapping functions, while a Payload<T, R>
type encapsulates mapping parameters. The joinParts
function is added to streamline ID string construction. Several mapping functions are refactored to utilize the new types and a helper function, improving clarity and maintainability by reducing code redundancy and enhancing type safety.
File | Change Summary |
---|---|
src/introspection/utils.ts | - Added type Mapper<T, R> for mapping functions. |
- Added type Payload<T, R> for mapping operation parameters. |
|
- Updated function signatures for typeNameToId , mapFields , mapPossibleTypes , mapDerivedTypes , and mapInterfaces to use Mapper . |
|
- Introduced joinParts function for ID string construction. |
|
- Refactored mapping functions to reduce redundancy and improve type safety. | |
- Added getDerivedTypes function for retrieving derived types from a schema. |
Hop along, oh code so bright,
With types and mappers, all feels right.
Join the parts, let strings unite,
Refactor, streamline, a coder's delight!
In the burrow of logic, we find our way,
Hopping through functions, come what may! 🐇✨
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
Summary by CodeRabbit
New Features
joinParts
function for constructing ID strings more efficiently.getDerivedTypes
function for better retrieval of derived types from schemas.Refactor