Skip to content

Validation for query variables #15

@jsonmaur

Description

@jsonmaur

First of all, thanks a ton for this, it really helped me learn GraphQL. I wanted to suggest an addition in part 7 when you talk about creating custom scalar types for fine-grained validation. What you have there doesn't work at all if a query is using variables instead of arguments. That requires the validation to occur in parseValue instead of parseLiteral.

For example, if I have a custom scalar type defined using the docs you have currently (with only parseLiteral, this will be validated:

mutation {
  createUser (email: "invalidemail") { ... }
}

but this will not:

mutation signup ($email: Email!) {
  createUser (email: $email) { ... }
}

I'll submit a PR for this, hopefully it will clear things up for anyone using validation on queries with variables.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions