ldd / gatsby-source-github-api

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

Limitations #6

Closed kosirm closed 5 years ago

kosirm commented 6 years ago

Hi, I'm really interested in using github as a gatsby source with new github graphql api, but I'm not sure if there is api for tree / node implemented yet. If I can use it only for listing issues etc. it's not really valuable source for me. I would like to access json files saved in github. Is this possible?

ldd commented 6 years ago

So! I am not sure if I understand you correctly, but let me give you an example:

https://github.com/ldd/gatsby-starter-github-portfolio/blob/master/gatsby-config.js

In there, I use the graphQL API to access the readme.md text. In that same project, I use some cute tricks to find the first image in the text, etc.

Anyways, if your question is "can I access the code saved in github"? The answer is yes, for sure!

I can even add a little section on how to do it because it is not 100% clear. (It took me some time to find it)

Otherwise, you may have a more complicated question, but if you clarify it, I can surely try to help!

ldd commented 6 years ago

further comment for anybody who sees this:

query { 
  user( login: "ldd") { 
    repositories(first: 11){
      edges {
        node {
          readme: object(expression:"master:package.json"){
                    ... on Blob{
                      text
                    }
                  }
        }
      }
    }
  }
}

That'll get you the package.json contents for some of my repositories.

Sources: https://stackoverflow.com/questions/44137710/github-graphql-equivalent-of-the-contents-api

kosirm commented 6 years ago

Oh, man, that's revelation for me, didn't know it's possible at all... Thank you so much for the info and for your time! 😄 👍