Skip to content

Conversation

@SlavaUtesinov
Copy link
Contributor

This is a possible fix of the issue #5.

@sungam3r sungam3r added the bugfix Pull request that fixes a bug label Dec 7, 2021
@sungam3r sungam3r added this to the 5.0 milestone Dec 7, 2021
@sungam3r sungam3r requested a review from Shane32 December 7, 2021 09:45
@sungam3r
Copy link
Member

sungam3r commented Dec 7, 2021

@SlavaUtesinov Thanks to fix the oldest bug!

Copy link
Member

@Shane32 Shane32 left a comment

Choose a reason for hiding this comment

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

Can we please add a test with failing validation with a query of this nature:

query a {
  ...frag1
}
query b {
  ...frag1
}
fragment frag1 on Query {
  # adminField should fail validation
  adminField
}

Ideally it would also allow this query when testing for operation a, but this could be a future enhancement:

query a {
  # a field that passes validation
  userField
}
query b {
  ...frag1
}
fragment frag1 on Query {
  # adminField should fail validation
  adminField
}

@SlavaUtesinov
Copy link
Contributor Author

I've added desired tests.

Comment on lines +62 to +72
if (belongs)
{
return;
}

belongs = node is FragmentSpread fragmentSpread && fragmentSpread.Name == fragment.Name;

if (node != null)
{
node.Visit(Visit, 0);
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if (belongs)
{
return;
}
belongs = node is FragmentSpread fragmentSpread && fragmentSpread.Name == fragment.Name;
if (node != null)
{
node.Visit(Visit, 0);
}
if (!belongs)
{
if (!(belongs = node is FragmentSpread fragmentSpread && fragmentSpread.Name == fragment.Name))
node.Visit(Visit, 0);
}

@codecov-commenter
Copy link

Codecov Report

Merging #171 (5c766a7) into develop (29d27da) will increase coverage by 3.03%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #171      +/-   ##
===========================================
+ Coverage    80.56%   83.60%   +3.03%     
===========================================
  Files            9        9              
  Lines          211      250      +39     
  Branches        32       41       +9     
===========================================
+ Hits           170      209      +39     
  Misses          32       32              
  Partials         9        9              
Impacted Files Coverage Δ
...aphQL.Authorization/AuthorizationValidationRule.cs 97.87% <100.00%> (+1.50%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 29d27da...5c766a7. Read the comment docs.

@sungam3r
Copy link
Member

sungam3r commented Dec 8, 2021

Also see #29. I think #29 should not be a blocker for this PR.

@sungam3r
Copy link
Member

sungam3r commented Dec 8, 2021

@Shane32 ?

@Shane32
Copy link
Member

Shane32 commented Dec 8, 2021

I need to re-review

@SlavaUtesinov
Copy link
Contributor Author

@Shane32 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Pull request that fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

In multi-query documents, trigger authorization rules on targeted queries only

4 participants