graphql icon indicating copy to clipboard operation
graphql copied to clipboard

Mutations: When non-null fields are not specified, the query should report errors

Open aweiker opened this issue 9 years ago • 10 comments

Currently if a non-null field is no specified in the mutation, the mutation will still execute even though it should return an error.

http://facebook.github.io/graphql/#sec-Non-Null

GraphiQL will indicate that the query is bad, but it will still submit it and the query will get executed.

aweiker avatar Feb 12 '16 22:02 aweiker

I think there is a todo in the executor that mentions this if you want to investigate

joshprice avatar Feb 13 '16 00:02 joshprice

I was planning on digging in this weekend or next week.

Sent from my iPad

On Feb 12, 2016, at 4:47 PM, Josh Price [email protected] wrote:

I think there is a todo in the executor that mentions this if you want to investigate

— Reply to this email directly or view it on GitHub.

aweiker avatar Feb 13 '16 01:02 aweiker

For more info here is what the Node implementation returns when not providing an id param and also when passing in unknown args:


{
  "errors": [
    {
      "message": "Field \"post\" argument \"id\" of type \"String!\" is required but not provided."
    }
  ]
}


{
  "errors": [
    {
      "message": "Unknown argument \"foo\" on field \"post\" of type \"BlogQueries\"."
    },
    {
      "message": "Field \"post\" argument \"id\" of type \"String!\" is required but not provided."
    }
  ]
}      

AdamBrodzinski avatar Feb 15 '16 17:02 AdamBrodzinski

Is somebody currently working on this? Otherwise I started working on adding some error and null checking and could probably get it done this week.

erikstenlund avatar Feb 29 '16 01:02 erikstenlund

This is being handled as a part of validation.

-Aaron

On Feb 28, 2016, at 5:06 PM, Erik Stenlund [email protected] wrote:

Is somebody currently working on this? Otherwise I started working on adding some error and null checking and could probably get it done this week.

— Reply to this email directly or view it on GitHub.

aweiker avatar Feb 29 '16 01:02 aweiker

@aweiker Is this still in progress? Do you guys need any help?

bringking avatar Nov 30 '16 18:11 bringking

I believe this is done as a part of #82.

aweiker avatar Nov 30 '16 19:11 aweiker

@aweiker okay cool, is there an example or a way to add errors to the error list that gets returned to the client?

bringking avatar Nov 30 '16 21:11 bringking

With the latest version you actually need to raise an error in order for it to get added to the error result. Prior to this refactoring you could return an error tuple.

aweiker avatar Nov 30 '16 21:11 aweiker

@aweiker raising an error worked great. Thank you for the clarification!

bringking avatar Dec 01 '16 01:12 bringking