Graphback: The loader.load() function must be called with a value,but got: null.

Created on 12 Aug 2020  路  6Comments  路  Source: aerogear/graphback

It seems that the dataloader, if a relation does not exist, throws this error: The loader.load() function must be called with a value,but got: null. This happens even if the relation is nullable.

Here's my example query:

        query ($twilioParentCallSid: String!) {
            findCalls(filter: {
                twilio_parent_call_sid: {
                    eq: $twilioParentCallSid
                }
            }) {
                items {
                    id
                    duration
                    billable_duration
                    ignore_during_audit
                    direction
                    origin_phone
                    marchex_recommendation
                    audit_result
                    twilio_parent_call_sid
                    destination_phone
                    action_item {
                        id
                    }
                    user {
                        id
                    }
                    company {
                        id
                        pod {
                            id
                        }
                        voicemail_audio_file_name
                        voicemail_text
                        queue_audio_file_name
                        callbacks_allowed
                    }
                    contact {
                        id
                        status
                        phone_number
                        sales
                    }
                    duration_events(filter: {
                        valid: {
                            eq: true
                        }
                    }) {
                        id
                        type
                        timestamp
                        description
                        user {
                            id
                        }
                    }
                }
            }
        }  

Here's what is returned:

  "errors": [
    {
      "message": "The loader.load() function must be called with a value,but got: null.",
      "locations": [
        {
          "line": 19,
          "column": 21
        }
      ],
      "path": [
        "findCalls",
        "items",
        0,
        "action_item"
      ]
    },
    {
      "message": "The loader.load() function must be called with a value,but got: null.",
      "locations": [
        {
          "line": 22,
          "column": 21
        }
      ],
      "path": [
        "findCalls",
        "items",
        0,
        "user"
      ]
    }
  ],
  "data": {
    "findCalls": {
      "items": [
        {
          "id": "147",
          "duration": 0,
          "billable_duration": 0,
          "ignore_during_audit": false,
          "direction": 0,
          "origin_phone": "REDACTED",
          "marchex_recommendation": "PASS",
          "audit_result": "NOT_AUDITED",
          "twilio_parent_call_sid": "REDACTED",
          "destination_phone": "REDACTED",
          "action_item": null,
          "user": null,
          "company": {
            "id": "1",
            "pod": {
              "id": "1"
            },
            "voicemail_audio_file_name": null,
            "voicemail_text": null,
            "queue_audio_file_name": null,
            "callbacks_allowed": true
          },
          "contact": {
            "id": "1",
            "status": 0,
            "phone_number": "REDACTED",
            "sales": false
          },
          "duration_events": []
        }
      ]
    }
  }
}

And some more potentially useful information with a stack trace:

{"errors":[{"message":"The loader.load() function must be called with a value,but got: null.","locations":[{"line":19,"column":21}],"path":["findCalls","items",0,"action_item"]},{"message":"The loader.load() function must be called with a value,but got: null.","locations":[{"line":22,"column":21}],"path":["findCalls","items",0,"user"]}],"data":{"findCalls":{"items":[{"id":"147","duration":0,"billable_duration":0,"ignore_during_audit":false,"direction":0,"origin_phone":"REDACTED","marchex_recommendation":"PASS","audit_result":"NOT_AUDITED","twilio_parent_call_sid":"REDACTED","destination_phone":"REDACTED","action_item":null,"user":null,"company":{"id":"1","pod":{"id":"1"},"voicemail_audio_file_name":null,"voicemail_text":null,"queue_audio_file_name":null,"callbacks_allowed":true},"contact":{"id":"1","status":0,"phone_number":"REDACTED","sales":false},"duration_events":[]}]}}}
    at /var/task/services/graphback/graphback.js:98:23
    at Generator.next (<anonymous>)
    at fulfilled (/var/task/services/graphback/graphback.js:5:58)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)

In the case of this query, user and action_item are both nullable types, so this error should not be occuring

bug

Most helpful comment

This will require trivial fix. We going to resolve it once team wakes up :)

All 6 comments

Automatically generated comment to notify maintainers
/cc @craicoverflow, @machi1990, @wtrocki

I actually think this is a critical issue if my analysis is correct. Any nullable relations could throw this error, and now I'm not sure how many of my queries that have nullable types are ticking time bombs.

This will require trivial fix. We going to resolve it once team wakes up :)

Alright!!!

@lastmjs we dropped 0.16.0-alpha4 to take care of this issue. Mind checking and see it fixes the issue for your. Feel free to re-open if it's not the case.

It works! Awesome work again

Was this page helpful?
0 / 5 - 0 ratings