Skip to content
This repository was archived by the owner on Nov 12, 2025. It is now read-only.
This repository was archived by the owner on Nov 12, 2025. It is now read-only.

Port validation rules from the reference implementation #93

@ianhoffman

Description

@ianhoffman

We should port the validation rules from the reference implementation. The code for these rules can be found here.

Porting rules is fairly straightforward. You can generally port the code in an almost one-to-one fashion. The AST used by the reference implementation is very similar to the one we use. Our tests are different, but it's still useful to refer to the reference implementation to make sure we're testing at least most of what they're testing. Those tests can be found here.

Here are a couple example PRs in which I ported over rules:

You'll notice in the PR which ports KnownArgumentNamesRule I also updated the TypeInfo construct. At a high level, when we visit the AST during validation, we also move through the GraphQL schema so that when we point to a given AST node, we're also pointing to a corresponding schema node, should one exist. For example, if we traverse the AST to a field called User, we also point to the User object in the schema. TypeInfo handles this synchronization between the schema and AST, but I didn't port the entire thing when porting the reference implementation, so there still may be pieces you need to transfer over. The full reference code for TypeInfo can be found here. In general, you just need to find the switch statement for the AST node you want to handle in TypeInfo's enter and leave methods and then adapt that code. Our implementation of TypeInfo is here. Of course, reach out to me with any questions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions