refactor: re-write gen_gql_schema.rs #1510 #2012
Closed
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:
In this PR, the gen_gql_schema.rs file has been updated to address code quality and performance issues, specifically:
Enhanced Functionality:
Introduced new functions for better modularity and readability, including write_all_directives, write_all_input_types, write_property, write_directive, and others. These functions streamline the code and reduce redundancy.
Documentation:
Added comments and documentation to clarify the purpose and functionality of various functions and structures, improving code maintainability.
Improved Indentation Handling:
Implemented IndentedWriter to manage indentation consistently across the generated GraphQL schema, ensuring more readable output.
Optimized Type Handling:
Improved handling of schema types, including arrays and objects, by modularizing type writing logic into functions like write_type, write_array_validation, and write_object_validation.
Directive and Object Handling:
Refined logic for writing directives and objects, including better handling of entity mappings and directive properties, enhancing flexibility and robustness.
Enhanced Scalability:
Improved the handling of custom scalars and extended types, allowing for more scalable and extensible schema generation.
Code Cleanup:
Removed redundant code, fixed minor bugs, and applied general code cleanups to improve performance and readability.
These changes collectively improve the maintainability, readability, and extensibility of the GraphQL schema generation process.
Issue Reference(s):
Fixes #.1510
Build & Testing:
cargo test
successfully../lint.sh --mode=fix
to fix all linting issues raised by./lint.sh --mode=check
.Checklist:
<type>(<optional scope>): <title>