ldd / gatsby-source-github-api

Pull data into Gatsby from Github API v4
MIT License
65 stars 10 forks source link

Errors handling #19

Closed pgalwa closed 4 years ago

pgalwa commented 4 years ago

Hey, could You add error handling for graphql requests? It's simple. I did in my fork :)

In gatsby-node.js you have to do something like this:

 fetchFromGithub(url, token, graphQLQuery, variables).then(result => {
      createNode({
        data: result.data,
        id: result.id || uuid(),
        errors: result.errors || [],

:)

It will be very helpful for users cuz sometimes even github throws an error :)

ldd commented 4 years ago

Interesting proposal. I like it.

Yet, perhaps there are other parts of the result that people want?

What about something like

...
 fetchFromGithub(url, token, graphQLQuery, variables).then(result => {
      createNode({
        data: result.data,
        id: result.id || uuid(),
        rawResult: result,
...
pgalwa commented 4 years ago

Sounds good :) It might be helpful for debugging

ldd commented 4 years ago

Done. Published to npm as version 0.2.0

Let me know if it works as intended, or if there are more changes you need.

Thanks for writing this bug report and using software I wrote.