graphql-spec icon indicating copy to clipboard operation
graphql-spec copied to clipboard

Editorial: Fix cases in validation where technically a crash could occur due to non-existent definitions

Open JoviDeCroock opened this issue 6 months ago • 3 comments

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

  • https://github.com/graphql/graphql-js/blob/16.x.x/src/validation/rules/VariablesInAllowedPositionRule.ts#L46
  • https://github.com/graphql/graphql-js/blob/8a16e93cb8a98b0f773164d7da6215aa47a85746/src/validation/rules/OverlappingFieldsCanBeMergedRule.ts#L266

JoviDeCroock avatar Jul 05 '25 07:07 JoviDeCroock

Deploy Preview for graphql-spec-draft ready!

Name Link
Latest commit 6cc621e719eeecc80d8d1c3d8062352613a177cd
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.

netlify[bot] avatar Jul 05 '25 07:07 netlify[bot]

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 avatar Nov 07 '25 11:11 benjie

Deploy Preview for graphql-spec-draft ready!

Name Link
Latest commit d65f5607b4dc0f641bcd8183d4d44ba96c18b7f2
Latest deploy log https://app.netlify.com/projects/graphql-spec-draft/deploys/690f08e9fc3e800008cf8867
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.

netlify[bot] avatar Nov 08 '25 09:11 netlify[bot]