GQL Server
Project structure, packages, and programming patterns are an always evolving thing for me, but I've been particularly happy with this one. I'm sure a year from now I'll be doing things a bit differently, but I wanted to take this time to create a time-capsule.
My hope is that others may get use out of this example and maybe even provide feedback so that I can also improve.
If you'd like to comment on anything or ask questions, feel free to create an new issue.
Table of Contents
- Typescript
- Config
- Logging
- Functional Core, Imperative Shell
- Directory Structure
- Developer Workflow
- My Personal Style
- Databases
- GraphQL
- Context
Typescript
Config
Logging
Functional Core, Imperative Shell
https://www.destroyallsoftware.com/screencasts/catalog/functional-core-imperative-shell
Directory Structure
I 100% agree with Dan Abramov and encourage everyone to experiement with their own projects to find out what makes sense for them.
That being said, I do think that for more junor programmers who are still figuring out what good separation of concerns even means, having something more structured put in place by a senior developer or something more experienced with the codebase can be a lifesaver.
The one thing that I do come back to as a guiding principal for directory structure is dependencies. It's for this reason that I'm a big fan of using the Barell Pattern.
Barell Pattern
If you are interested in this pattern, I'd suggest checking out this very well written (and short) guide: https://basarat.gitbook.io/typescript/main-1/barrel
This pattern plays very nice with my peronal style of having lots of small files and pooling the things that should be externaly available to other layers of the application in a single place. The biggest downside is that you have a rediculous number of files named "index.ts" which can be frustrating when using "find by filename" functionality in text editors / IDEs.