graphql-go / graphql

An implementation of GraphQL for Go / Golang
MIT License
9.82k stars 836 forks source link

Add nullvalue #696

Open xxlv opened 2 weeks ago

xxlv commented 2 weeks ago

Description:

I have noticed that the go-graphql project does not handle null values for input correctly. According to the GraphQL specification GraphQL Spec, there are two scenarios for handling null values in inputs:

  1. When the input is required, null is not an acceptable value.
  2. When the input parameter is optional, the null literal is acceptable.

For example, the following is not allowed:

Def:

NonNullField(arg: String!): String

Use:

{
    NonNullField(arg: null) // not allowed
}

After completing my changes, I found that @krasish has done similar work in pull request #683 , which has not yet been merged.

Please review this implementation, thank you very much.

coveralls commented 2 weeks ago

Coverage Status

coverage: 92.056% (+0.008%) from 92.048% when pulling d0c80278c4b8b6cb1ff63b6b3c5f67e67af5834b on xxlv:add-nullvalue into f2b39caf7c92cab3f3f92726b55f59c74f54cfbc on graphql-go:master.

coveralls commented 2 weeks ago

Coverage Status

coverage: 92.056% (+0.008%) from 92.048% when pulling c5ca6e6f198f083125b0d51c117bb2dd0111b050 on xxlv:add-nullvalue into f2b39caf7c92cab3f3f92726b55f59c74f54cfbc on graphql-go:master.

coveralls commented 2 weeks ago

Coverage Status

coverage: 92.072% (+0.02%) from 92.048% when pulling 72d7caaa6197c0348c9455e4d75c8b94cb0ec198 on xxlv:add-nullvalue into f2b39caf7c92cab3f3f92726b55f59c74f54cfbc on graphql-go:master.