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
/public
.DS_Store
.env.development
.env.production

View File

@ -1,5 +1,9 @@
const config = require('./config.js')
require('dotenv').config({
path: `.env.${process.env.NODE_ENV}`
})
module.exports = {
siteMetadata: {
// spread all of our config values here
@ -36,6 +40,23 @@ module.exports = {
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',
options: {

View File

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

View File

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

View File

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