Skip to content

Conversation

@JoviDeCroock
Copy link
Member

@JoviDeCroock JoviDeCroock commented Jul 5, 2025

We have a few cases where in validation rules we rely on a different rule ensuring that the definition for usage exists.

  • Overlapping Fields, we use a Fragment Definition looked up by a SpreadName that potentially does not exist
  • VariablesOfCorrectType, we look up a VariableDefinition from a VariableName which could potentially not exist.

In GraphQL JS we already guard against this in a few places

@netlify
Copy link

netlify bot commented Jul 5, 2025

Deploy Preview for graphql-spec-draft ready!

Name Link
🔨 Latest commit 6cc621e
🔍 Latest deploy log https://app.netlify.com/projects/graphql-spec-draft/deploys/6868d2ddff037f0008fa6a75
😎 Deploy Preview https://deploy-preview-1180--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 project configuration.

Copy link
Member

@benjie benjie left a comment

Choose a reason for hiding this comment

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

Good call, both of these are covered by separate validation rules and the same issue (e.g. undefined variable) should never produce multiple validation failures.

@benjie benjie added ✏️ Editorial PR is non-normative or does not influence implementation 💡 Proposal (RFC 1) RFC Stage 1 (See CONTRIBUTING.md) 🚀 Next Stage? This RFC believes it is ready for the next stage and removed ✏️ Editorial PR is non-normative or does not influence implementation labels Nov 7, 2025
@benjie
Copy link
Member

benjie commented Nov 7, 2025

I feel like this is an editorial correction, however since it's in the algorithms I'm going to make it an RFC and we can decide if it's actually editorial during the relevant WG. This is already implemented in GraphQL.js so we could fast-track this to RFC3 IMO.

cc @graphql/tsc

@benjie benjie moved this to Needs representation at WG in Benjie's GraphQL tasks Nov 7, 2025
- Let {variableName} be the name of {variableUsage}.
- Let {variableDefinition} be the {VariableDefinition} named {variableName}
defined within {operation}.
- If no {variableDefinition} can be found, return.
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be caught before by 5.8.3 All Variable Uses Defined?

Copy link
Member

Choose a reason for hiding this comment

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

The validation rules don't run in a specific order, they run in parallel / independently. So yes to "is it caught by All Variable Uses Defined?" and no to "before".

Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense. As an implementer, more guidance on the order would be welcome but definitely out of scope for this PR.

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

Labels

🚀 Next Stage? This RFC believes it is ready for the next stage 💡 Proposal (RFC 1) RFC Stage 1 (See CONTRIBUTING.md)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants