router icon indicating copy to clipboard operation
router copied to clipboard

Using `@defer` in a Subscription returns `router-bridge` error vs. nicer user-facing erorr

Open lleadbet opened this issue 1 year ago • 0 comments

Describe the bug

When using a subscription in the router and using a deferred fragment within, you'll get the following error:

{
    "errors": [
        {
            "message": "value retrieval failed: router bridge error: the deno runtime raised an error: `request: couldn't receive response couldn't deserialize payload `3689970476626457495`: `deno: couldn't deserialize response : `Error(\"invalid neither null nor empty object: found Object {\\\"code\\\": String(\\\"QUERY_PLANNING_FAILED\\\"), \\\"exception\\\": Object {\\\"stacktrace\\\": Array [String(\\\"Error: @defer is not supported on subscriptions\\\")]}}\", line: 0, column: 0)``.`",
            "extensions": {
                "code": "INTERNAL_SERVER_ERROR"
            }
        }
    ]
}

We do have a nicer error in the logs: an error happened in the worker runtime Error: @defer is not supported on subscriptions but the client-facing error is noisy and can be improved.

To Reproduce

Use defer in a subscription request, such as:

subscription Subscription {
  realtimeThing {
    id
    ... @defer {
      name
    }
  }
}

Expected behavior

A nicer user-facing error.

lleadbet avatar Mar 11 '24 15:03 lleadbet