Skip to content

Latest commit

 

History

History

README.md

GitHub GraphQL Activity

Activity that queries GitHub. It implements the account WIT interface. The account interface fetches basic info like repositories, contributions etc. for a given account.

Prerequisites

Classic GitHub token with read:org permission is required. The token must be accesible as GITHUB_TOKEN environment variable.

export GITHUB_TOKEN="..."

Running the activity

Build the activity and run Obelisk with obelisk-local.toml.

just build
obelisk server run --deployment ./obelisk-local.toml

In another terminal run the activity.

obelisk execution submit -f .../account.account-info -- '"your-github-login"'

Testing

Unit testing

cargo nextest run

Integration testing

export TEST_GITHUB_TOKEN="..."
export TEST_GITHUB_LOGIN="..."
export TEST_GITHUB_REPO="..."
# optinally export TEST_GITHUB_STARGAZERS_CURSOR="..."
cargo nextest run -- --ignored

Ad-hoc GraphQL query for debugging

QUERY='
query QueryStargazers($repo: URI!, $page: Int!, $cursor: String) {
  resource(url: $repo) {
    ... on Repository {
      __typename
      stargazers(first: $page, after: $cursor) {
        nodes {
          login
        }
        edges {
          cursor
        }
      }
    }
  }
}
'
echo '
{"query":"'$(echo $QUERY)'", "variables":{"repo":"obeli-sk/obelisk", "page":2}}
' | curl -X POST \
-H "User-Agent: test" \
-H "Authorization: Bearer $GITHUB_TOKEN" https://api.github.com/graphql \
-d @-