Skip to content
This repository has been archived by the owner on Aug 11, 2020. It is now read-only.
/ ts-gql-node Public archive

🥳 TypeScript + GraphQL + Node.js template

License

Notifications You must be signed in to change notification settings

5u4/ts-gql-node

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TypeScript + GraphQL + Node.js

Travis (.org) MIT License GitHub tag

A clean template combining TypeScript, GraphQL and Node.js together.

How to use

  1. Clone/fork repository
git clone https://github.com/senhungwong/ts-gql-node.git
  1. Install dependency
cd ts-gql-node && npm install  # OR yarn
  1. Set app environment
cp .env.example .env
  1. Start server
npm start  # OR yarn serve

General development process

  1. GraphQL schema

    • Create GraphQL schema file and store them into ./src/schemas/

    • Merge schemas

      # For modularization, schemas are defined in multiple files
      # The following script merges them into one schema
      npm run merge-schemas  # OR yarn merge-schemas
      
    • Generate TypeScript definition

      # We can generate TypeScript type definition by using the schema
      npm run gql2ts  # OR yarn gql2ts
      
  2. GraphQL resolver

    • Create service in ./src/services/. All complex logics should be here

    • Map field services to resolvers in ./src/resolvers/

    • Write service tests in ./tests/ and test

      npm run test  # OR yarn test
      
    • Validate arguments in ./src/validators/ and map them in ./src/validators/index.ts

Example

See treehole implementation:

GraphQL Original

About

🥳 TypeScript + GraphQL + Node.js template

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published