Not sure how else to name this issue, but I'm having a bizarre issue.
I have a recursive relationship of User->ReferredBy (also a User). When I issue a request to retrieve Users, I ask for most of the data on the main user, but keep the data I request on the ReferredBy relationship to a minimum. But if I don't request non-nullable fields on the ReferredBy relationship, the response ends up being an HTTP 400 with errors attached.
In the example below, one of the non-nullable fields on my User entity is points. It always an int and has a value of >= 0. If I do not request points on the ReferredBy relation, then an exception is thrown. However, I can skip points on the top level User without any issues.
This is the request I am issuing:
query GetUsers($cursor: String, $query: String) {
users(after: $cursor, order: {name: "ASC"}, query: $query) {
edges {
cursor
node {
...UserFields
}
}
pageInfo {
endCursor
hasNextPage
}
}
}
fragment UserFields on User {
id
referredBy {
id
name
email
referralToken
}
name
email
referralToken
points
}
This results in an exception being thrown with the following response:
{
"errors": [
{
"debugMessage": "Cannot return null for non-nullable field User.points.",
"message": "Internal server error",
"category": "internal",
"locations": [
{
"line": 29,
"column": 3
}
],
"path": [
"users",
"edges",
2,
"node",
"points"
]
}
],
"data": {
"users": {
"edges": [
{
"cursor": "MA==",
"node": {
"id": "/users/84cc1b30-6875-11e8-8dd5-f393655f85db",
"referredBy": null,
"name": "Administrator",
"email": "admin@test.com",
"referralToken": "623C33",
"points": 50
}
},
{
"cursor": "MQ==",
"node": {
"id": "/users/3d2f955c-8005-11e8-925e-ffad03401b2c",
"referredBy": {
"id": "/users/65dc3b1e-69de-11e8-8be9-5beebe7a0b50",
"name": "Test User 1",
"email": "test1@test.com",
"referralToken": "058D51"
},
"name": "Test User 2",
"email": "test2@test.com",
"referralToken": "A4965A",
"points": 50
}
},
{
"cursor": "Mg==",
"node": null
}
],
"pageInfo": {
"endCursor": "Mg==",
"hasNextPage": false
}
}
}
The only way I can get rid of this error is to request all non-nullable fields on the ReferredBy User relation. The weird part is that I can completely skip these non-nullable fields on the top level User, but I must always request them on child User nodes.
Not sure how else to name this issue, but I'm having a bizarre issue.
I have a recursive relationship of User->ReferredBy (also a User). When I issue a request to retrieve Users, I ask for most of the data on the main user, but keep the data I request on the ReferredBy relationship to a minimum. But if I don't request non-nullable fields on the ReferredBy relationship, the response ends up being an HTTP 400 with errors attached.
In the example below, one of the non-nullable fields on my User entity is
points. It always an int and has a value of >= 0. If I do not requestpointson the ReferredBy relation, then an exception is thrown. However, I can skippointson the top level User without any issues.This is the request I am issuing:
This results in an exception being thrown with the following response:
{ "errors": [ { "debugMessage": "Cannot return null for non-nullable field User.points.", "message": "Internal server error", "category": "internal", "locations": [ { "line": 29, "column": 3 } ], "path": [ "users", "edges", 2, "node", "points" ] } ], "data": { "users": { "edges": [ { "cursor": "MA==", "node": { "id": "/users/84cc1b30-6875-11e8-8dd5-f393655f85db", "referredBy": null, "name": "Administrator", "email": "admin@test.com", "referralToken": "623C33", "points": 50 } }, { "cursor": "MQ==", "node": { "id": "/users/3d2f955c-8005-11e8-925e-ffad03401b2c", "referredBy": { "id": "/users/65dc3b1e-69de-11e8-8be9-5beebe7a0b50", "name": "Test User 1", "email": "test1@test.com", "referralToken": "058D51" }, "name": "Test User 2", "email": "test2@test.com", "referralToken": "A4965A", "points": 50 } }, { "cursor": "Mg==", "node": null } ], "pageInfo": { "endCursor": "Mg==", "hasNextPage": false } } }The only way I can get rid of this error is to request all non-nullable fields on the ReferredBy User relation. The weird part is that I can completely skip these non-nullable fields on the top level User, but I must always request them on child User nodes.