-
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| 'hive': minor | ||
| --- | ||
|
|
||
| adjust change capture and resolvers to optionally provide a full list or the simplified list of | ||
| changes |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ import type { | |
| SuccessfulSchemaCheckMapper, | ||
| } from '../module.graphql.mappers'; | ||
| import { Injectable, Scope } from 'graphql-modules'; | ||
| import { DiffRule } from '@graphql-inspector/core'; | ||
| import { Storage } from '../../shared/providers/storage'; | ||
| import { formatNumber } from '../lib/number-formatting'; | ||
| import { SchemaManager } from './schema-manager'; | ||
|
|
@@ -35,27 +36,70 @@ export class SchemaCheckManager { | |
| return !!(schemaCheck.breakingSchemaChanges?.length || schemaCheck.safeSchemaChanges?.length); | ||
| } | ||
|
|
||
| getSafeSchemaChanges(schemaCheck: SchemaCheck) { | ||
| getSafeSchemaChanges(schemaCheck: SchemaCheck, simplifyChanges: boolean = true) { | ||
| if (!schemaCheck.safeSchemaChanges?.length) { | ||
| return null; | ||
| } | ||
|
|
||
| if (simplifyChanges) { | ||
| /** | ||
| * @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({ | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 I'd be interested in hearing recommendations for how maybe we can avoid this typecasting. |
||
| changes: schemaCheck.safeSchemaChanges as any, | ||
| oldSchema: undefined as any, | ||
| newSchema: undefined as any, | ||
| config: undefined, | ||
| }) as unknown as typeof schemaCheck.safeSchemaChanges; | ||
|
Comment on lines
+49
to
+54
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using |
||
| } | ||
|
|
||
| return schemaCheck.safeSchemaChanges; | ||
| } | ||
|
|
||
| getAllSchemaChanges(schemaCheck: SchemaCheck) { | ||
| getAllSchemaChanges(schemaCheck: SchemaCheck, simplifyChanges: boolean = true) { | ||
| if (!schemaCheck.safeSchemaChanges?.length && !schemaCheck.breakingSchemaChanges?.length) { | ||
| return null; | ||
| } | ||
|
|
||
| return [...(schemaCheck.breakingSchemaChanges ?? []), ...(schemaCheck.safeSchemaChanges ?? [])]; | ||
| const changes = [ | ||
| ...(schemaCheck.breakingSchemaChanges ?? []), | ||
| ...(schemaCheck.safeSchemaChanges ?? []), | ||
| ]; | ||
| if (simplifyChanges) { | ||
| /** | ||
| * @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({ | ||
| changes: changes as any, | ||
| oldSchema: undefined as any, | ||
| newSchema: undefined as any, | ||
| config: undefined, | ||
| }) as unknown as typeof changes; | ||
| } | ||
|
|
||
| return changes; | ||
| } | ||
|
|
||
| getBreakingSchemaChanges(schemaCheck: SchemaCheck) { | ||
| getBreakingSchemaChanges(schemaCheck: SchemaCheck, simplifyChanges: boolean = true) { | ||
| if (!schemaCheck.breakingSchemaChanges?.length) { | ||
| return null; | ||
| } | ||
|
|
||
| if (simplifyChanges) { | ||
| /** | ||
| * @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({ | ||
| changes: schemaCheck.breakingSchemaChanges as any, | ||
| oldSchema: undefined as any, | ||
| newSchema: undefined as any, | ||
| config: undefined, | ||
| }); | ||
| } | ||
|
|
||
| return schemaCheck.breakingSchemaChanges; | ||
| } | ||
|
|
||
|
|
||
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.