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

3.13 Directive validation edits #1089

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jbellenger
Copy link

@jbellenger jbellenger commented Apr 2, 2024

The Validation section for Directive types is a little out of step with the validation sections for the other types. In particular, while the grammar definition of Directive requires one or more directive locations, this requirement isn't mentioned in the validation section.

Compare this to the validation sections for other types with "one or more" requirements:

  • 1. An Object type must define one or more fields.
  • 1. A Union type must include one or more member types.
  • 1. An Enum type must define one or more unique enum values.
  • 1. An Input Object type must define one or more input fields.
  • 1. An Interface type must define one or more fields.

This PR updates Directive validation to be more consistent with the validation sections of other types:

  1. Add a "one or more" requirement as the first validation rule
  2. Use "Directive" instead of "directive"
  3. Rename the section from "Validation" to "Type Validation"

While this PR just clarifies the existing spec, I suspect it might be common for implementations to not check for non-empty directive locations.
I've updated graphql-java and can do the same for graphql-js if I get a tentative OK on this PR.

- add requirement that DirectiveLocations is non empty
- Validation -> TypeValidation
- s/directive/Directive in most places
Copy link

linux-foundation-easycla bot commented Apr 2, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

Copy link

netlify bot commented Apr 2, 2024

Deploy Preview for graphql-spec-draft ready!

Name Link
🔨 Latest commit cb28e5e
🔍 Latest deploy log https://app.netlify.com/sites/graphql-spec-draft/deploys/660c0982d0969f00080df8fa
😎 Deploy Preview https://deploy-preview-1089--graphql-spec-draft.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.


1. A directive definition must not contain the use of a directive which
1. A Directive definition must include at least one DirectiveLocation.
Copy link
Author

@jbellenger jbellenger Apr 2, 2024

Choose a reason for hiding this comment

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

Why is this worded differently from the other "one or more" constraints?
If this were worded in the same style as Objects, it would read "A Directive must define one or more DirectiveLocations"

To be pedantic, while this sentence would attempt to use a plural form of the DirectiveLocation token, it could also be interpreted as a plural form of the DirectiveLocations token, which is given a distinct definition in Appendix B.4 and does not match the Directive grammar.

I thought that a phrasing that avoided pluralizing DirectiveLocation would be less ambiguous, though recognize there's also value in using consistent language. I'm open to feedback.

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.

None yet

1 participant