Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

usePortsMetadata GraphQL error #173

Closed
ecklf opened this issue Jul 31, 2019 · 2 comments
Closed

usePortsMetadata GraphQL error #173

ecklf opened this issue Jul 31, 2019 · 2 comments

Comments

@ecklf
Copy link
Contributor

ecklf commented Jul 31, 2019

Description

Cannot spin up a local dev environment with a fresh clone + npm i + npm run dev:local

Steps to Reproduce

  1. Clone repo
  2. npm i
  3. npm run dev:local

Expected Behavior

No build errors

Actual Behavior

GraphQL Error: Unknown type "GitHub_Repository".

Environment and Versions

  • What is the version of Nord or the port project you are running?
    nord-docs

  • Have you tried to reproduce it on different OS environments and if yes is the behavior the same for all?
    no

  • Are you using any additional CLI arguments to run the project?
    no

  • Are you using any additional CLI arguments to start the build tool task/script other than defined by the project?
    no

If you've installed Node.js on your system you can run envinfo via [npx]

## System:
 - OS: macOS 10.14.6
 - CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
 - Memory: 2.60 GB / 16.00 GB
 - Shell: 5.7.1 - /usr/local/bin/zsh
## Binaries:
 - Node: 10.15.3 - ~/.nvm/versions/node/v10.15.3/bin/node
 - Yarn: 1.16.0 - ~/.yarn/bin/yarn
 - npm: 6.10.2 - ~/.nvm/versions/node/v10.15.3/bin/npm
 - Watchman: 4.9.0 - /usr/local/bin/watchman
## IDEs:
 - Android Studio: 3.4 AI-183.6156.11.34.5522156
 - Emacs: 26.2 - /usr/local/bin/emacs
 - Nano: 2.0.6 - /usr/bin/nano
 - VSCode: 1.36.1 - /usr/local/bin/code
 - Vim: 8.0 - /usr/bin/vim
 - Xcode: 10.3/10G8 - /usr/bin/xcodebuild
## Languages:
 - Bash: 3.2.57 - /bin/bash
 - Java: 11.0.1 - /usr/bin/javac
 - Perl: 5.18.4 - /usr/bin/perl
 - PHP: 7.1.23 - /usr/bin/php
 - Python: 2.7.16 - /usr/local/bin/python
 - Ruby: 2.3.7 - /usr/bin/ruby

Stack Trace and Error Messages

error GraphQL Error Unknown type "GitHub_Repository".
  file: /private/tmp/nord-docs/src/hooks/usePortsMetadata.js

   1 |
   2 |   {
   3 |     github {
   4 |       search(query: "nord NOT nord-docs in:name user:arcticicestudio sort:stars-desc", type: REPOSITORY, first: 100) {
   5 |         repositoryCount
   6 |         edges {
   7 |           node {
>  8 |             ... on GitHub_Repository {
     |                    ^
   9 |               id
  10 |               name
  11 |               releases(last: 1) {
  12 |                 edges {
  13 |                   node {
  14 |                     name
  15 |                     url
  16 |                   }
  17 |                 }
  18 |               }
@arcticicestudio
Copy link
Contributor

arcticicestudio commented Aug 1, 2019

Hi @impulse, the problem is that the project in an early development state and there are no information about the project itself yet. As you can see on the roadmap the repository is also kind of a case study for me to build a project from scratch in a clean and well documented way. Like described in #1 the main goal is to create a sine-source-of-truth for the Nord project which is why this is kind of a opinionated project and currently not really laid out to be easily useable by others.

Anyway, the problem you're facing is the fact that the used official gatsby-source-graphql plugin requires an valid GitHub API token in order to fetch data from the GraphQL API. The data is used to display information about all the port project repositories on the ports page like the amount of stars or the latest version as well as linking to the public URL of the repository without "hardcoding" it into the code base.
The GitHub API token is stored in the both .env files for production & development that are both encrypted using the de-facto standard tool git-crypt (see .git-crypt folder in the repository root).

In order to use the project you need to

  • create a GitHub API token to be able to fetch (public) data from the GraphQL API
  • delete both .env files and replace them with your own ones or use any other package or script to set and expose the required environment variables that contains the GitHub API token. nord-docs looks for the environment variables named NORD_DOCS_GITHUB_API_TOKEN_READONLY_PUBLIC for the token, but you can adjust the code to use any other name.
    Please be careful to not expose these publicly but only on your local system, otherwise also encrypt them to store them in a public repository.

@ecklf
Copy link
Contributor Author

ecklf commented Aug 1, 2019

Hi @impulse, the problem is that the project in an early development state and there are no information about the project itself yet. As you can see on the roadmap the repository is also kind of a case study for me to build a project from scratch in a clean and well documented way. Like described in #1 the main goal is to create a sine-source-of-truth for the Nord project which is why this is kind of a opinionated project and currently not really laid out to be easily useable by others.

Anyway, the problem you're facing is the fact that the used official gatsby-source-graphql plugin requires an valid GitHub API token in order to fetch data from the GraphQL API. The data is used to display information about all the port project repositories on the ports page like the amount of stars or the latest version as well as linking to the public URL of the repository without "hardcoding" it into the code base.
The GitHub API token is stored in the both .env files for production & development that are both encrypted using the de-facto standard tool git-crypt (see .git-crypt folder in the repository root).

In order to use the project you need to

  • create a GitHub API token to be able to fetch (public) data from the GraphQL API
  • delete both .env files and replace them with your own ones or use any other package or script to set and expose the required environment variables that contains the GitHub API token. nord-docs looks for the environment variables named NORD_DOCS_GITHUB_API_TOKEN_READONLY_PUBLIC for the token, but you can adjust the code to use any other name.
    Please be careful to not expose these publicly but only on your local system, otherwise also encrypt them to store them in a public repository.

Thanks for the writeup :). Currently learning Gatsby and GraphQL so this helps^^.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants