Skip to content

[APPENG-1215] Add the function to handle directive usage changed type changes #1

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

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Gravewalker666
Copy link

🚨 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.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as
    expected)
  • This change requires a documentation update

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 A
  • Test B

Test Environment:

  • OS:
  • @graphql-inspector/...:
  • NodeJS:

Checklist:

  • I have followed the
    CONTRIBUTING doc and the
    style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

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...

@Gravewalker666 Gravewalker666 marked this pull request as draft May 7, 2025 15:17
Comment on lines +89 to +97
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',
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +1050 to +1058
[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;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar story to above, this is where the changetype is actually declared.

@@ -68,6 +68,7 @@ export function changesInField(
},
});

// TODO: Heshan -> Introduce a mutual option to this function to detect changes in directive usage
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +125 to +148
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;
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PS: there could unfortunately be a lot of conflicts because we are essentially editing the same file when we divide up the work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant