fix: chema sdl resolver to ignore auto fix composite schema execution…#7614
Conversation
Summary of ChangesHello @mskorokhodov, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request refines the schema resolution process by introducing a conditional bypass for composite schema auto-fixing in environments where a supergraph SDL is not applicable, such as monoliths. Concurrently, it enhances the user experience on the laboratory page by integrating error handling for schema introspection, ensuring that any issues during schema fetching are gracefully managed and communicated to the user. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request correctly prevents autoFixCompositeSchemaSdl from running on monolith projects by checking for the existence of supergraphSDL. Additionally, it introduces robust error handling on the frontend by wrapping the schema building logic in a try-catch block, which prevents UI crashes from invalid SDLs. I've suggested a minor refactoring for improved clarity in the backend logic, aligning with the principle of prioritizing readability, and a more precise error message for the user in the frontend.
| if (!schemaVersion.supergraphSDL) { | ||
| return schemaVersion.compositeSchemaSDL; | ||
| } | ||
|
|
||
| return schemaVersion.compositeSchemaSDL | ||
| ? this.autoFixCompositeSchemaSdl(schemaVersion.compositeSchemaSDL, schemaVersion.id) | ||
| : null; |
There was a problem hiding this comment.
While the logic is correct, it can be simplified to improve readability and reduce redundancy. You can restructure it to first handle the null case for compositeSchemaSDL, then the monolith case, and finally the federation case.
if (!schemaVersion.compositeSchemaSDL) {
return null;
}
if (!schemaVersion.supergraphSDL) {
return schemaVersion.compositeSchemaSDL;
}
return this.autoFixCompositeSchemaSdl(schemaVersion.compositeSchemaSDL, schemaVersion.id);References
- Prioritize readability over conciseness. Avoid using the logical OR assignment operator (
||=) when a more explicit if/else block is clearer, especially for operations like initializing an array in a map.
| try { | ||
| return introspectionFromSchema(buildSchema(sdl)); | ||
| } catch (err) { | ||
| toast.error('Failed to fetch schema', { |
There was a problem hiding this comment.
The error message "Failed to fetch schema" is slightly misleading. The schema SDL has been fetched, but building the GraphQLSchema object from it has failed. A more accurate message would be "Failed to build schema".
| toast.error('Failed to fetch schema', { | |
| toast.error('Failed to build schema', { |
📚 Storybook DeploymentThe latest changes are available as preview in: https://pr-7614.hive-storybook.pages.dev |
|
🐋 This PR was built and pushed to the following Docker images: Targets: Platforms: Image Tag: |
💻 Website PreviewThe latest changes are available as preview in: https://pr-7614.hive-landing-page.pages.dev |
… in case of monolith
c088a44 to
3c89d23
Compare
… in case of monolith
Background
Description
Schema sdl resolver to ignore auto fix composite schema execution in case of monolith
Checklist