Skip to content

InputFieldAddedChange when adding a non-null type field with a default value is not a breaking change #2881

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

janeli1
Copy link

@janeli1 janeli1 commented Apr 4, 2025

Description

Updated InputFieldAddedChange logic to correctly handle non-null fields with default values. Previously, adding such fields was flagged as breaking; this change ensures they are recognized as not breaking.

Fixes # (#2880)

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.
Updated input.test.ts to cover this change.

Provide instructions so we can reproduce.
Reproduce step is provided in reported issue.

Please also list any relevant details for your test configuration

  • Test A
  • Test B

Test Environment:

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

janeli1 added 2 commits April 4, 2025 18:52
Summary: update cases.

Reviewers: ureview

JIRA Issues: RF-19036

Differential Revision: https://code.uberinternal.com/D17076739
@@ -37,6 +40,12 @@ describe('input', () => {
expect(change.d.message).toEqual(
"Input field 'd' of type 'String' was added to input object type 'Foo'",
);
// Non-nullable with default
expect(change.e.criticality.level).toEqual(CriticalityLevel.Dangerous);
Copy link

Choose a reason for hiding this comment

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

Why is this dangerous? This seems simply non-breaking to me. What's the definition of dangerous vs critical?

Copy link
Author

Choose a reason for hiding this comment

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

Dangerous is the original criticality level defined by core for this rule. So I would like to keep it as the same. For our internal rule, we will override it as non-breaking.

expect(change.e.criticality.level).toEqual(CriticalityLevel.Dangerous);
expect(change.e.type).toEqual('INPUT_FIELD_ADDED');
expect(change.e.message).toEqual(
"Input field 'e' of type 'String!' was added to input object type 'Foo'",
Copy link

Choose a reason for hiding this comment

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

Should this message include include that is has a default?

Input field 'e' of type 'String!' with a default value was added to input object type 'Foo'

Copy link
Author

Choose a reason for hiding this comment

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

ack. Updated the logic to handle this.

@janeli1
Copy link
Author

janeli1 commented Apr 14, 2025

Hi, @kamilkisiela Appreciate your eyes on this PR.

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

Successfully merging this pull request may close these issues.

2 participants