graphql-demo

Example GraphQL app that renders latest issues and issue comments for a given GitHub repository.

MIT License

Stars
1

GitHub PRs & Comments

Example GraphQL app that renders latest pull requests and their first comments for a given GitHub repository. The purpose of this app is to contrast the use of GitHub's REST API v3 vs. its GraphQL API v4. Written in TypeScript, uses the React UI library and Tailwind CSS for styling.

Providing an access token

To use either of GitHub's APIs, a personal access token is required. GitHub provides instructions on how to create access tokens.

To make the token available to this app, create a file src/token.ts with the following content:

export const token = '<your-token-goes-here>'

Building and running

After cloning this repository, install dependencies:

npm i

To then compile the TypeScript code into JavaScript and start the development server:

npm run dev

Switching between REST and GraphQL

The code in fetchREST.ts and fetchGraphQL.ts is responsible for fetching required data from GitHub's REST and respectively GraphQL APIs. This code is invoked from the fetchData function in App.tsx. Comment in the desired function.

License

MIT