gatsby-source-github icon indicating copy to clipboard operation
gatsby-source-github copied to clipboard

Documentation

Open smerth opened this issue 7 years ago • 0 comments
trafficstars

Hi there DSchau,

Thanks for the plugin... Unfortunately I can't get it to work and I think thats a combination of inexperience and documentation.

Here's what I have done

@ gatsby-config.js

    {
      resolve: "@dschau/gatsby-source-github",
      options: {
        headers: {
          Authorization: `Bearer MY-TOKEN-HERE` // https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/
        },
        queries: [
          `query { 
            viewer { 
              login
              name
              bio
              id
              company
              avatarUrl
            }
          }`
        ]
      }
    }

Of course I am using my own token in the above snippet.

That query, in the above gatsby-config.js snippet, when I use it at https://developer.github.com/v4/explorer/, when I am logged-in, returns my account data as expected.

When I run gatsby develop the site appears to compile OK. But when I go to http://localhost:8000/___graphql I can't make that query.

query { 
  viewer { 
    login
    name
    bio
    id
    company
    avatarUrl
    }
  }

returns the error

{
  "errors": [
    {
      "message": "Cannot query field \"viewer\" on type \"RootQueryType\".",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ]
    }
  ]
}

So I don't know what I am doing wrong...

Also I am not clear on the relation between the queries in the gatsby-config.js file and the queries I write in my React component files... Do I have to write a query twice... once in gatsby-config.js and again in every react component where I want to use the data?

Can you give me any insite into how to get the data flowing?

Thanks,

Smerth

smerth avatar Aug 29 '18 20:08 smerth