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

[schema-first] Non-nullable types are not validated when query uses variables. #651

Closed
radubuciuceanu opened this issue Mar 24, 2019 · 4 comments
Assignees
Milestone

Comments

@radubuciuceanu
Copy link

radubuciuceanu commented Mar 24, 2019

Describe the bug
When the query sent to server uses variables, non-nullable types are not validated. I've tested it only on schema-first approach.

To Reproduce
Let say we have the following schema:

"Input used for posting a message to server."
input MessageInput {
    "The author of the message."
    author: String!
    "The content of the message."
    content: String!
}

type Message {
    ...
}

"One of the three root graph nodes. It's used for posting data to server."
type Mutation {
    "It's used to post a message to server."
    createMessage(
        "The message that will be posted to server."
        input: MessageInput!
    ): Message!
}

type Query {
    ...
}

The Query and Message types aren't important. Let's assume we have them written in a right way.

When the following query is executed:

mutation($input:MessageInput!) {
  createMessage(input:$input) {
    id
    author
    content
  }
}

# Variables section
{
  "input": {
    "author": "Random author here."
  }
}

You can see that the field content is not populated.

The Resolver is invoked with Author: "Random author here." and Content:null.

Expected behavior
The Resolver should not be invoked because the content field of the MessageInput graph type is marked as String!. The Executer should throw an error because we've inserted an invalid query.

Desktop:

  • Ubuntu
  • 18.10

Additional context
Used package version: 0.8.1-rc2

@michaelstaib
Copy link
Member

Awesome bug description 👍 do not get them so detailed most of the time. I will look into that tonight and include it in our patch release.

@michaelstaib michaelstaib added this to the 0.8.1 milestone Mar 24, 2019
@michaelstaib michaelstaib self-assigned this Mar 24, 2019
@radubuciuceanu
Copy link
Author

@michaelstaib Communication is our all 😉 Thx you.

@michaelstaib
Copy link
Member

This one is now fixed with #659

@michaelstaib
Copy link
Member

@radubuciuceanu

The fix is now included into 0.8.1-rc.3

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

No branches or pull requests

2 participants