Skip to content

[#4169] UniqueInputFieldNamesRule incorrectly identifies field names as duplicates within and/or array #4170

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

Closed

Conversation

vctqs1
Copy link

@vctqs1 vctqs1 commented Aug 17, 2024

Fixed: #4169

To address the issue, use additional variables to store ListValue nodes and check if the duplicate field is present in the ListValue

Copy link

linux-foundation-easycla bot commented Aug 17, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

});
},
leave() {
knownNamesInList = Object.create([]);
Copy link
Member

Choose a reason for hiding this comment

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

I think this would also need to use a stack else it would make list --> object --> field --> list lose track of the outer object when it bubbles back up

Copy link
Author

Choose a reason for hiding this comment

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

Let me address the case of this list --> object --> field --> list.

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 changed the approach to use a stack to hold listValue[] and pop the state when it exits. I’ve also added a test for this case. Could you please help me review it again? @JoviDeCroock

Copy link
Member

Choose a reason for hiding this comment

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

I was checking your tests and all of these also pass in current 16.x.x so I don't think this shows any issue in the current shape

Copy link
Author

Choose a reason for hiding this comment

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

ah yeah, you're right. Sorry, I misread the format; the issue was with the {} inside the single big object (labeled in blue).
image

something like [{Id: {}, Id: {}}]

our tests cases was [{Id: {}}, {Id: {}}]

Copy link
Member

@JoviDeCroock JoviDeCroock Aug 18, 2024

Choose a reason for hiding this comment

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

Yes but

  it('duplicate input object fields in objects of array', () => {
    expectErrors(`
      {
        field(arg: [{Id: {}, Id: {}}])
      }
    `).toDeepEqual([
      {
        message: 'There can be only one input field named "Id".',
        locations: [
          { line: 3, column: 22 },
          { line: 3, column: 30 },
        ],
      },
    ]);
  });

Correctly reports it as an error

Copy link
Author

Choose a reason for hiding this comment

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

Oh, based on that, I think the issue is with Salesforce rather than the current validation rule. Thank you for your response, thank you for spending time to help me validation again.

Copy link
Member

Choose a reason for hiding this comment

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

No worries, happy to help, if anything pops up feel free to reach out/create an issue so we can get to the bottom of this.

Copy link
Author

Choose a reason for hiding this comment

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

Copy link
Author

Choose a reason for hiding this comment

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

thank you, I'll the close PR right now. @JoviDeCroock

@vctqs1 vctqs1 closed this Aug 18, 2024
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.

UniqueInputFieldNamesRule incorrectly identifies field names as duplicates within and/or array
2 participants