- NodeJS - Server
- Apollo GraphQL Server
- Apollo Graph Manager
- Jest - Unit Testing
- TypeScript - Dev Language
- Lerna - Monorepo management
- Yarn - Npm runner
-
Clone this repository using SSH:
git clone [email protected]:otomer/monorepo-graphql-typescript.git
-
Install Lerna, Typescript and Yarn globally
yarn global add lerna typescript yarn
-
Bootstrap all packages in the monorepo (?)
lerna bootstrap
That's it, you are all set!
- Run:
lerna bootstrap
(Run this only if you pull some cruical package changes) - Run:
lerna run compile
(Compiles all packages) - Navigate to:
/packages/services/myservice
- Start the application
yarn start
5 Navigate to http://localhost:4000/graphql
6. Execute one of the examples given in /packages/services/myservice/examples.md
Breaking down the basic structure and the configurations
packages/
libs
agify // Agify 3rd party lib integration, for example
dist/
src/
index.ts
package.json // package-specific deps and scripts
tsconfig.json // config used to build for publishing
services
myservice/ // service package, just for example
dist/
src/
server.ts
package.json // package-specific deps and scripts
README.md // shown in npmjs.com. included in npm artifact
tsconfig.json // config used to build for publishing
.babelrc // project-wide babel configuration
.editorconfig // config for consistent coding styles between editors/IDEs
.eslintignore // eslint (linter) ignored directories/files
.eslintrc // eslint (linter) configuration
.gitignore // github's default node gitignore with customizations
.prettierignore // prettier ignored directories/files
.prettierrc // prettier configuration
jest.config.js // jest configuration
lerna.json // lerna configuration
package.json // common dev deps and workspace-wide scripts
README.md // workspace-wide information. shown in github
tsconfig.json // common typescript configuration
yarn.lock // the only lock file in the repo. all packages combined
Test runner is jest. To run all eligible tests across all packages in the monorepo:
yarn test
Tools being used:
- Prettier - Opinionated Code Formatter.
- ESlint - Static code analysis tool for identifying and reporting problematic patterns found in JavaScript code.
All tools are configured in project level and takes part during development, commit, open Pull Requests and in our CI/CD flow.
- Run Lint:
yarn lint
- Run Prettier:
yarn prettier
To integrate Prettier in your editor, download this plugin: for Visual Studio Code / for WebStorm
For WebStorm: To run prettier on auto-save - Go to .idea/watcherTasks.xml
file and enable it.
Tomer Ovadia @ github