Graph error message "TypeError: result.json is not a function"


I’m using Netlify Graph to query a GitHub file so I can display its content in an 11ty page generated by a Serverless(Neltify) Function.

I’m able to get Netlify Graph to access the file from a private repo. While the Generate Handler button does not seem to work, netlify graph:pull does create the Netlify Function.

From an 11ty page, I use a form’s action to call the Function where I set it to use either the Client’s access token or mine. It then calls netlifyGraph which is where things break, for either token.

Request from ::ffff: GET /.netlify/functions/dynamic
Response with status 200 in 1623 ms.
CLI session closed, stopping monitoring...
CLI session closed, stopping monitoring...
Request from ::ffff: GET /.netlify/functions/TestResults?fetchGitHub=fetchGitHub
Using client's access token: false
TestResults.js: event.netlifyGraphToken: XXXXX
netlifyGraph.index.js accessToken: XXXXX
netlifyGraph.index.js response: {"errors":[{"message":"Missing auth for GitHub. Please reauthenticate.","path":["gitHub"],"extensions":{"service":"github","type":"auth/missing-auth","traceId":"aca330f4-7c8e-4581-a771-9d88b38d63a1"}}],"data":{"gitHub":null},"extensions":{"metrics":{"api":{"avoidedRequestCount":0,"requestCount":0,"totalRequestMs":0.0,"byHost":[]}}}}
TypeError: result.json is not a function
    at /workspaces/rosie-core/netlify/functions/netlifyGraph/index.js:202:23
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

There are a few interesting things going on:

  1. The error message is not sent to the console. I found it by stepping through the code and adding console.log("netlifyGraph.index.js response:", result); after line 184.
  2. I also console.log the access token from the TestResults Function to netlifyGgraph/index.js and it exists.
  3. On the Graph UI, under Connected APIs and services for GitHub, both Graph and API Authentication are enabled.
  4. From the Graph Session page, I’m able to run the query and get the expected results.
  5. The Generated Handler and query in VS Code are the same as in UI
  6. To reauthenticate, I have logged out of Netlify and GitHub and logged in accordingly.

I’ll be happy to share the site URL in a private message.

Any help would be greatly appreciated. It feels like I’m so close :slight_smile:


Hey there, @stevenmilstein :wave:

Thanks for such a thorough writeup. Can you please share your latest deploy log? Additionally, you can DM my your site. I will share this with the appropriate staff members and we will investigate further. Thanks!