-
Notifications
You must be signed in to change notification settings - Fork 122
Generate a full list of changes on schema check, and add an argument to filter change lists #7395
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
base: schema-proposals-schema
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @jdolle, 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 significantly enhances the schema change detection and reporting capabilities. It addresses a limitation where nested schema changes were not fully captured, by modifying the schema check process to record all changes. Furthermore, it introduces a new GraphQL argument to allow clients to dynamically request either a comprehensive or a simplified list of schema changes, improving both accuracy and usability for schema evolution management. Highlights
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
|
| this.logger.debug('Comparing Schemas'); | ||
|
|
||
| const changes = await diff(existing, incoming, [DiffRule.simplifyChanges]); | ||
| const changes = await diff(existing, incoming, rules); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change exposes the rules option up the callstack so it can be modifies.
🚀 Snapshot Release (
|
| Package | Version | Info |
|---|---|---|
@graphql-hive/cli |
0.57.0-alpha-20251210003101-e6a477cba341d23819c344c9c2168be7477d6f55 |
npm ↗︎ unpkg ↗︎ |
hive |
8.13.0-alpha-20251210003101-e6a477cba341d23819c344c9c2168be7477d6f55 |
npm ↗︎ unpkg ↗︎ |
📚 Storybook DeploymentThe latest changes are available as preview in: https://pr-7395.hive-storybook.pages.dev |
| * @todo modify the simplifyChanges rule to loosen the argument requirements. This rule | ||
| * doesn't need more information than the change type and path fields. | ||
| */ | ||
| return DiffRule.simplifyChanges({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rule's type definition is very strict and that our SchemaCheck model slightly modifies the change structure, but the only thing this specific rule is using is a change's path and a type, which are unmodified. So technically this is safe to use here even though the typing is a mess.
I'd be interested in hearing recommendations for how maybe we can avoid this typecasting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces a mechanism to fetch a full, non-simplified list of schema changes by adding a simplifyChanges argument to the relevant GraphQL fields. The implementation correctly modifies the schema, resolvers, and underlying providers to support this functionality. The approach of storing the full list of changes and filtering them at the resolver level is sound. I've included a few suggestions for improving code clarity and safety.
| return DiffRule.simplifyChanges({ | ||
| changes: schemaCheck.safeSchemaChanges as any, | ||
| oldSchema: undefined as any, | ||
| newSchema: undefined as any, | ||
| config: undefined, | ||
| }) as unknown as typeof schemaCheck.safeSchemaChanges; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using as any here bypasses type safety. While the @todo notes a plan to fix this upstream, a safer intermediate step could be to define a local, less strict context type that only includes the properties you are providing (like changes) and cast to that. This would make the code more self-documenting and slightly safer against future changes.
packages/services/api/src/modules/schema/providers/schema-version-helper.ts
Show resolved
Hide resolved
💻 Website PreviewThe latest changes are available as preview in: https://pr-7395.hive-landing-page.pages.dev |
|
🐋 This PR was built and pushed to the following Docker images: Targets: Platforms: Image Tag: |
| }) | ||
| @cache<SchemaVersion>(version => version.id) | ||
| private async _getSchemaChanges(schemaVersion: SchemaVersion) { | ||
| @cache<{ version: SchemaVersion; simplified: boolean }>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the cache typing requires everything be passed as a single argument.
I then cache these versions separately to avoid having to recalculate the simplified or full list.
… or the simplified list of changes
4e78a51 to
e6a477c
Compare
Background
Schema proposals require a full list of changes to be able to patch the schemas. Currently, our schema checks are responsible for calculating this list of changes and saving it to the DB. However, checks don't include the nested changes. e.g. if a new type is added, checks don't care about showing that type's new fields.
Description
This change modifies the check behavior so that it captures all changes and then the resolvers use the Rule from graphql-inspector to filter out the nested types.