chris-langager / gql-server

A time capsule of how I'm making GQL servers with Typescript and Node.js in 2020.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

  1. Typescript
  2. Config
  3. Logging
  4. Functional Core, Imperative Shell
  5. Directory Structure
  6. Developer Workflow
  7. My Personal Style
  8. Databases
  9. GraphQL
  10. 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.

Developer Workflow

Nodemon

My Personal Style

No Classes

Small Files

Databases

Postgres

Migrations on Startup

GraphQL

Code Generation

Context

Authentication

About

A time capsule of how I'm making GQL servers with Typescript and Node.js in 2020.


Languages

Language:TypeScript 96.3%Language:TSQL 3.7%