[APPENG-1215] Add the function to handle directive usage changed type changes#1
[APPENG-1215] Add the function to handle directive usage changed type changes#1Gravewalker666 wants to merge 4 commits intomasterfrom
Conversation
| DirectiveUsageUnionMemberChanged: 'DIRECTIVE_USAGE_UNION_MEMBER_CHANGED', | ||
| DirectiveUsageEnumAdded: 'DIRECTIVE_USAGE_ENUM_ADDED', | ||
| DirectiveUsageEnumRemoved: 'DIRECTIVE_USAGE_ENUM_REMOVED', | ||
| DirectiveUsageEnumChanged: 'DIRECTIVE_USAGE_ENUM_CHANGED', | ||
| DirectiveUsageEnumValueAdded: 'DIRECTIVE_USAGE_ENUM_VALUE_ADDED', | ||
| DirectiveUsageEnumValueRemoved: 'DIRECTIVE_USAGE_ENUM_VALUE_REMOVED', | ||
| DirectiveArgumentUsageEnumValueAdded: 'DIRECTIVE_USAGE_ARGUMENT_ENUM_VALUE_ADDED', | ||
| DirectiveArgumentUsageEnumValueRemoved: 'DIRECTIVE_USAGE_ARGUMENT_ENUM_VALUE_REMOVED', | ||
| DirectiveArgumentUsageEnumValueChanged: 'DIRECTIVE_USAGE_ARGUMENT_ENUM_VALUE_CHANGED', |
There was a problem hiding this comment.
All of these DirectiveUsage<insert-type>Changed change types were prematurely added by me. We need to turn them into much granular added, removed, and changed types. Just like how it's done for types DirectiveArgumentUsageEnumValue<Added | Removed | Changed> here.
| [ChangeType.DirectiveUsageUnionMemberChanged]: DirectiveUsageUnionMemberChangedChange; | ||
| [ChangeType.DirectiveUsageEnumAdded]: DirectiveUsageEnumAddedChange; | ||
| [ChangeType.DirectiveUsageEnumRemoved]: DirectiveUsageEnumRemovedChange; | ||
| [ChangeType.DirectiveUsageEnumChanged]: DirectiveUsageEnumChangedChange; | ||
| [ChangeType.DirectiveUsageEnumValueAdded]: DirectiveUsageEnumValueAddedChange; | ||
| [ChangeType.DirectiveUsageEnumValueRemoved]: DirectiveUsageEnumValueRemovedChange; | ||
| [ChangeType.DirectiveArgumentUsageEnumValueAdded]: DirectiveArgumentUsageEnumValueAddedChange; | ||
| [ChangeType.DirectiveArgumentUsageEnumValueRemoved]: DirectiveArgumentUsageEnumValueRemovedChange; | ||
| [ChangeType.DirectiveArgumentUsageEnumValueChanged]: DirectiveArgumentUsageEnumValueChangedChange; |
There was a problem hiding this comment.
similar story to above, this is where the changetype is actually declared.
| }, | ||
| }); | ||
|
|
||
| // TODO: Heshan -> Introduce a mutual option to this function to detect changes in directive usage |
There was a problem hiding this comment.
I've added this TODO comment to everyplace I could find that we need to call directiveUsageChanged function defined in directive-usage.ts file.
A good example would be what's done in packages/core/src/diff/enum.ts already.
| export function directiveUsageArgumentChanged<K extends keyof KindToPayload>( | ||
| kind: K, | ||
| payload: KindToPayload[K]['input'], | ||
| directive: ConstDirectiveNode, | ||
| oldVersion: ConstArgumentNode, | ||
| newVersion: ConstArgumentNode, | ||
| ): Change { | ||
| if (isOfKind(kind, Kind.ENUM_VALUE_DEFINITION, payload)) { | ||
| return directiveArgumentUsageEnumValueChangedFromMeta({ | ||
| type: ChangeType.DirectiveArgumentUsageEnumValueChanged, | ||
| meta: { | ||
| enumName: payload.type.name, | ||
| enumValueName: payload.value.name, | ||
| directiveName: directive.name.value, | ||
| argumentName: oldVersion.name.value, | ||
| oldArgumentValue: stringOfValueNode(oldVersion.value), | ||
| oldArgumentType: oldVersion.value.kind, | ||
| newArgumentValue: stringOfValueNode(newVersion.value), | ||
| newArgumentType: newVersion.value.kind, | ||
| }, | ||
| }); | ||
| } | ||
| return {} as any; | ||
| } |
There was a problem hiding this comment.
For every DirectiveArgumentUsage<insert-type>Changed change type we introduce we need to add another if clause here and define and call a similar function to the above.
Same should be done for directiveUsageArgumentAdded and directiveUsageArgumentRemoved functions above.
There was a problem hiding this comment.
PS: there could unfortunately be a lot of conflicts because we are essentially editing the same file when we divide up the work
🚨 IMPORTANT: Please do not create a Pull Request without creating an issue first.
Any change needs to be discussed before proceeding. Failure to do so may result in the rejection of
the pull request.
Description
Please include a summary of the change and which issue is fixed. Please also include relevant
motivation and context. List any dependencies that are required for this change.
Fixes # (issue)
Type of change
Please delete options that are not relevant.
expected)
Screenshots/Sandbox (if appropriate/relevant):
Adding links to sandbox or providing screenshots can help us understand more about this PR and take
action on it as appropriate
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can
reproduce. Please also list any relevant details for your test configuration
Test Environment:
@graphql-inspector/...:Checklist:
CONTRIBUTING doc and the
style guidelines of this project
Further comments
If this is a relatively large or complex change, kick off the discussion by explaining why you chose
the solution you did and what alternatives you considered, etc...