From 05de45573a347805ddcb7f2ddf578146903a119d Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Sat, 10 Nov 2018 17:33:44 +0100 Subject: [PATCH] prototype fetching repos from GitHub's GraphQL API --- .env.sample | 1 + .gitignore | 2 + gatsby-config.js | 21 +++++++ package.json | 2 + .../Repositories/RepositoryList.jsx | 1 + src/components/Repositories/index.jsx | 55 +++++++++++++------ 6 files changed, 64 insertions(+), 18 deletions(-) create mode 100644 .env.sample diff --git a/.env.sample b/.env.sample new file mode 100644 index 00000000..3b926cd6 --- /dev/null +++ b/.env.sample @@ -0,0 +1 @@ +GITHUB_TOKEN= diff --git a/.gitignore b/.gitignore index a2ab7551..524850f1 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,5 @@ yarn-error.log .cache /public .DS_Store +.env.development +.env.production diff --git a/gatsby-config.js b/gatsby-config.js index 770c8454..a954ca7e 100755 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -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: { diff --git a/package.json b/package.json index 59a5d5c5..74b6c802 100755 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/components/Repositories/RepositoryList.jsx b/src/components/Repositories/RepositoryList.jsx index f4579c5d..6cf77a0a 100644 --- a/src/components/Repositories/RepositoryList.jsx +++ b/src/components/Repositories/RepositoryList.jsx @@ -15,6 +15,7 @@ const RepositoryList = ({ repositories }) => ( key={item.name} name={item.name} description={item.description} + url={item.url} links={item.links} /> ))} diff --git a/src/components/Repositories/index.jsx b/src/components/Repositories/index.jsx index da70e7fb..36c1997c 100644 --- a/src/components/Repositories/index.jsx +++ b/src/components/Repositories/index.jsx @@ -29,30 +29,49 @@ const QuickRun = () => ( ) -const Repositories = () => ( - ( + { const repositories = data.allRepositoriesYaml.edges + const repositoriesGitHub = + data.github.organization.repositories.edges return (