Refactor Server and Client Codebases for Better Scalability and Type Safety #1
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.
Backend Refactoring: Apollo Server Enhancements
DataSources,Resolvers, andSchemainto their respective files. Previously, these were all housed withinindex.js, leading to clutter and maintainability challenges. This modular approach lays a solid foundation for future scaling, as it simplifies the introduction of new resolvers, data sources, and schema modifications without overcrowding the entry file.Frontend Enhancements: React Application Updates
Type Safety: Advanced the type safety of the project by isolating TypeScript types into a dedicated file. This move eradicates the use of
anytype, enforcing strict type checks across the application. This improvement minimizes runtime errors and enhances developer productivity through clearer type definitions.Query Optimization: Transitioned from
useQuerytouseLazyQueryfor GraphQL queries. This strategic shift prevents the automatic execution of queries on the component mount, allowing for more controlled query execution based on user interactions or specific conditions. This enhancement optimizes the application's performance and user experience.UI Improvements:
Impact
These changes collectively refine the codebase's structure, improve performance, and enhance the user interface, significantly contributing to the project's long-term success and scalability.
When using useQuery, double requests to the server are generated. Adding
skipdoes not solve the issue.First request to the server as the component mounts - no username.
Second request to the server.
After fix: By using
useLazyQueryinstead ofuseQuery.