This repository contains a small web application using GraphQL and Go on the backend and React with Apollo Client in TypeScript for the frontend. It's designed as a starting point for bootstrapping new web applications with Go and TypeScript.
If you find issues, please report them on the graphql-server issue tracker.
Go server:
- Reflection-based GraphQL server using zombiezen.com/go/graphql-server
- HTTP request logs sent to stdout
- Debug logging sent to stderr
- Graceful termination
- Unit test example
TypeScript client:
- Preconfigured React Router and Apollo Client
- Automatically generated types for GraphQL queries
- GraphQL Playground available by visiting /client/playground.html
- Unit test harness using Jest and Enzyme
- Webpack configuration ready for code splitting and build-time GraphQL parsing
Development:
- Provided Dockerfile for consistent builds and deployment to any container-based environment like Kubernetes
- Provided Heroku configuration for simple deployment
- Continuous Integration (CI) via GitHub Actions
- Tasks and editor settings for Visual Studio Code
Before getting started, you will need Go 1.13 or later, Node.js 12, and Adobe's go-starter tool. You may optionally want to install Docker.
Use the go-starter tool to create your repository.
go-starter zombiezen/graphql-go-app PROJECT
cd PROJECTTo run the app locally:
# In one terminal:
cd client && npm install && npm run watch
# In another terminal:
go build && ./<APPLICATION_NAME>Once you've got your environment set up, these are the files you will most likely want to edit next:
- schema.graphql: Service definition written in the GraphQL schema language.
If you make changes, run npm run graphql-codegenfrom theclientdirectory to update the TypeScript type definitions.
- main.go: Server code. Can be broken up into multiple Go files, like with any Go package.
- main_test.go: Server test code
- client/src/components/App.tsx: Top-level <App>React component
- client/src/components/App.test.tsx: Unit tests for the <App>component
- client/dist/style.css: Stylesheet
- client/dist/index.html: Entrypoint for the TypeScript client application.