'Silverstripe: how can I debug a GraphQL Error?
In Silverstripe, GraphQL provides an error in the browser console, but there is no backtrace, making debugging tricky. Is there a way to get a backtrace?
Solution 1:[1]
No, you can't turn any debugging on or something like that, but you can use the trick below.
To find out where the error occurs you add the backtrace call (as below), just before the location where the error occurs.
use SilverStripe\Dev\Backtrace;
class Foo
{
function Bar()
{
// conditional to only catch error
Backtrace::backtrace();
// actual error is below
}
}
Solution 2:[2]
I would recommend using XDebug, setting a couple of breakpoints on code that you know gets executed or which you suspect may be related to the problem, and stepping through the code with the debugger running.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Nicolaas Thiemen Francken |
Solution 2 | Guy Sartorelli |