Skip to content

henry74/simple-typescript-graphql-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple GraphQL Server (Apollo-based)

Setup

Making changes

Folder Hierarchy

├── Dockerfile
├── LICENSE
├── README.md
├── package.json
├── src
│   |── config
│   |   └── envVars.ts # load environment variables
│   ├── generatedTypes.ts # yarn generate; import for automatic type checking
│   ├── index.ts # launches server
│   ├── schema
│   │   ├── books # alternative schema can also be organized by entities
│   │   │   ├── index.ts
│   │   │   ├── mutations.ts
│   │   │   ├── queries.ts
│   │   │   └── types.ts
│   │   ├── index.ts # combine and export all typedefs and resolvers into single schema
│   │   ├── mutations # all mutations and associated resolvers
│   │   │   ├── index.ts
│   │   │   └── mutation.ts
│   │   ├── queries # match file name to query; can group queries into folders
│   │   │   ├── index.ts
│   │   │   └── query.ts
│   │   ├── subscriptions
│   │   └── types # all data and input types shared across queries, mutations, and other types
│   └── util  # utility libraries
│       └── logger.ts
├── tools
│   ├── codegen.yml # gql-gen command configuration
│   └── generate-gql.sh # launch server for generateTypes.ts; then kill process
├── tsconfig.json
└── yarn.lock

Change Log (Added)

  • Foundational code with sample query & mutation (playground @ /graphql)
  • Add generatedTypes.ts based on schema using yarn generate
  • Base-line folder structure and schema merging strategy
  • Dockerfile with health check
  • Add logger based on winston
  • GZIP compression
  • Handle environment variables

Todo

  • Setup instructions
  • dataloader
  • Authentication
  • RBAC using graphql-shield
  • Links to good type design examples
  • Middleware layer using graphql-middleware
  • 3rd Party REST API integration (w/ LRU caching)
  • Schema stitching