1
0
mirror of https://github.com/oceanprotocol/docs.git synced 2024-11-26 19:49:26 +01:00

prototype fetching repos from GitHub's GraphQL API

This commit is contained in:
Matthias Kretschmann 2018-11-10 17:33:44 +01:00
parent 64a172f4c4
commit 05de45573a
Signed by: m
GPG Key ID: 606EEEF3C479A91F
6 changed files with 64 additions and 18 deletions

1
.env.sample Normal file
View File

@ -0,0 +1 @@
GITHUB_TOKEN=

2
.gitignore vendored
View File

@ -5,3 +5,5 @@ yarn-error.log
.cache .cache
/public /public
.DS_Store .DS_Store
.env.development
.env.production

View File

@ -1,5 +1,9 @@
const config = require('./config.js') const config = require('./config.js')
require('dotenv').config({
path: `.env.${process.env.NODE_ENV}`
})
module.exports = { module.exports = {
siteMetadata: { siteMetadata: {
// spread all of our config values here // spread all of our config values here
@ -36,6 +40,23 @@ module.exports = {
path: `${__dirname}/node_modules/@oceanprotocol/art` path: `${__dirname}/node_modules/@oceanprotocol/art`
} }
}, },
{
resolve: 'gatsby-source-graphql',
options: {
typeName: 'GitHub',
fieldName: 'github',
// Url to query from
url: 'https://api.github.com/graphql',
// HTTP headers
headers: {
// Learn about environment variables: https://gatsby.app/env-vars
Authorization: `bearer ${process.env.GITHUB_TOKEN}`
},
// Additional options to pass to node-fetch
fetchOptions: {},
refetchInterval: 60
}
},
{ {
resolve: 'gatsby-transformer-remark', resolve: 'gatsby-transformer-remark',
options: { options: {

View File

@ -25,6 +25,7 @@
"gatsby-remark-responsive-iframe": "^2.0.6", "gatsby-remark-responsive-iframe": "^2.0.6",
"gatsby-remark-smartypants": "^2.0.6", "gatsby-remark-smartypants": "^2.0.6",
"gatsby-source-filesystem": "^2.0.8", "gatsby-source-filesystem": "^2.0.8",
"gatsby-source-graphql": "^2.0.6",
"gatsby-transformer-remark": "^2.1.12", "gatsby-transformer-remark": "^2.1.12",
"gatsby-transformer-sharp": "^2.1.8", "gatsby-transformer-sharp": "^2.1.8",
"gatsby-transformer-yaml": "^2.1.5", "gatsby-transformer-yaml": "^2.1.5",
@ -49,6 +50,7 @@
"test": "npm run lint" "test": "npm run lint"
}, },
"devDependencies": { "devDependencies": {
"dotenv": "^6.1.0",
"eslint": "^5.9.0", "eslint": "^5.9.0",
"eslint-config-oceanprotocol": "^1.3.0", "eslint-config-oceanprotocol": "^1.3.0",
"eslint-config-prettier": "^3.1.0", "eslint-config-prettier": "^3.1.0",

View File

@ -15,6 +15,7 @@ const RepositoryList = ({ repositories }) => (
key={item.name} key={item.name}
name={item.name} name={item.name}
description={item.description} description={item.description}
url={item.url}
links={item.links} links={item.links}
/> />
))} ))}

View File

@ -29,9 +29,7 @@ const QuickRun = () => (
</div> </div>
) )
const Repositories = () => ( const query = graphql`
<StaticQuery
query={graphql`
query { query {
allRepositoriesYaml { allRepositoriesYaml {
edges { edges {
@ -49,10 +47,31 @@ const Repositories = () => (
} }
} }
} }
github {
organization(login: "oceanprotocol") {
repositories(first: 100) {
edges {
node {
id
name
description
url
} }
`} }
}
}
}
}
`
const Repositories = () => (
<StaticQuery
query={query}
render={data => { render={data => {
const repositories = data.allRepositoriesYaml.edges const repositories = data.allRepositoriesYaml.edges
const repositoriesGitHub =
data.github.organization.repositories.edges
return ( return (
<div className={styles.repositories}> <div className={styles.repositories}>