Skip to content
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

Adds Enum Type Default Value Uses Inaccessible Value Rule #47

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

michaelstaib
Copy link
Member

No description provided.


ValidateArgumentDefaultValues():

- Let {arguments} be all arguments of fields and directives across all subgraphs
Copy link

Choose a reason for hiding this comment

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

Suggested change
- Let {arguments} be all arguments of fields and directives across all subgraphs
- Let {arguments} be all arguments of fields and directives across all source schemas


ValidateInputFieldDefaultValues():

- Let {inputFields} be all input fields of across all subgraphs
Copy link

Choose a reason for hiding this comment

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

Suggested change
- Let {inputFields} be all input fields of across all subgraphs
- Let {inputFields} be all input fields across all source schemas

- For each {argument} in {arguments}
- If {IsExposed(argument)} is true and has a default value:
- Let {defaultValue} be the default value of {argument}
- If not ValidateDefaultValue(defaultValue)
Copy link

Choose a reason for hiding this comment

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

Suggested change
- If not ValidateDefaultValue(defaultValue)
- If not {ValidateDefaultValue(defaultValue)}

- Let {type} be the type of {inputField}
- If {IsExposed(inputField)} is true and {inputField} has a default value:
- Let {defaultValue} be the default value of {inputField}
- if ValidateDefaultValue(defaultValue) is false
Copy link

Choose a reason for hiding this comment

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

Suggested change
- if ValidateDefaultValue(defaultValue) is false
- If {ValidateDefaultValue(defaultValue)} is false

**Explanatory Text**

This rule ensures that inaccessible enum values are not exposed in the composed schema through default values.
Output field arguments, input fields and directive arguments must only use enum values as their default value that is not annotated with the `@inaccessible` directive.
Copy link

Choose a reason for hiding this comment

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

Suggested change
Output field arguments, input fields and directive arguments must only use enum values as their default value that is not annotated with the `@inaccessible` directive.
Output field arguments, input fields, and directive arguments must only use enum values as their default value when not annotated with the `@inaccessible` directive.

Output field arguments, input fields and directive arguments must only use enum values as their default value that is not annotated with the `@inaccessible` directive.

In this example the `FOO` value in the `Enum1` enum is not marked with
`@inaccessible`, hence it doesn't violate the rule.
Copy link

Choose a reason for hiding this comment

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

Suggested change
`@inaccessible`, hence it doesn't violate the rule.
`@inaccessible`, hence it does not violate the rule.

}
```

This following example violates this rule because the default value for the field
Copy link

Choose a reason for hiding this comment

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

Suggested change
This following example violates this rule because the default value for the field
The following example violates this rule because the default value for the field

field: Enum1 = FOO
}

directive @directive1(arg: Enum1 = FOO) on FIELD_DEFINITION
Copy link

Choose a reason for hiding this comment

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

Should this be removed or described? It's not part of the example description above, and also not in the "good" example.

(same in the next counter-example)

BAR
}
```

Copy link

Choose a reason for hiding this comment

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

Missing description of counter-example.

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.

2 participants