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

Response returns null on a non-nullable type #275

Closed
theoks opened this issue Aug 8, 2018 · 3 comments · Fixed by #298
Closed

Response returns null on a non-nullable type #275

theoks opened this issue Aug 8, 2018 · 3 comments · Fixed by #298
Labels
bug Something isn't working

Comments

@theoks
Copy link

theoks commented Aug 8, 2018

I am a bit baffled by the way the framework deals with non-nullable types.

For example I have a mutation like that:

mutation SignUp($email: String!, $password: String!) {
  signUp(email: $email, password: $password) {
    success
  }
}

with the respective GraphQL schema:

signUp(email: String!, password: String!): Result!

If I run this mutation through a client, in such a way that I get back an error (eg in this case I pass an empty email, which returns an error to the client):

{
	"data": {
		"signUp": null
	},
	"errors": [
		{
			"message": "Database error: email cannot be empty, message: email cannot be empty
			"path": [
				"signUp"
			]
		}
	]
}

The issue is that the signUp field is not nullable, however the server responds with null. In the beginning I believed it was a client issue, however after opening an issue in the apollo-ios github repo it seems that there must be something off with the way the library handles nullability.

The issue is, that because the server nulls a non-nullable result, the client cannot handle correctly the error. Instead of getting back the correct error, it detects a null response (which should not be null) and reports the null value as the error.

@vektah
Copy link
Collaborator

vektah commented Aug 8, 2018

http://facebook.github.io/graphql/June2018/#sec-Errors-and-Non-Nullability

Looks like nulls should bubble up, and in this case data should be null.

@vektah vektah added the bug Something isn't working label Aug 8, 2018
@mikeifomin
Copy link
Contributor

mikeifomin commented Aug 9, 2018

Have faced with the same issue after an update from 0.3 to 0.4.1. All my schema now lack of a non nullable =(

@vektah
Copy link
Collaborator

vektah commented Aug 9, 2018

@mikeifomin that's a separate issue that should be fixed on master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants