Deprecated
Try a better version here https://github.com/entria/entria-fullstack
GraphQL DataLoader Boilerplate
Boilerplate using GraphQL and DataLoader
β TypeScript β
Check it out TS version of this boilerplate: https://github.com/entria/graphql-dataloader-boilerplate-ts
Blog Posts
- How to implement viewerCanSee in GraphQL
- Testing a GraphQL Server using Jest
- Parallel testing a GraphQL Server with Jest
- Encapsulating data on GraphQL using Loaders
Directory Structure
βββ /data/ # GraphQL generated schema
βββ /repl/ # Read-Eval-Print-Loop (REPL) configuration
βββ /scripts/ # Generate GraphQL schema script
βββ /src/ # Source code of GraphQL Server
β βββ /core/ # Core types and helper files, can be used like a global module
β βββ /interface/ # NodeInterface (Relay) and other GraphQL Interfaces
β βββ /modules/ # Modules (think on modules like isolated pieces of your code)
β β βββ /mutation/ # Module mutations (add an index file to be used on MutationType)
β β βββ /subscription/ # Module subscriptions (add an index file to be used on SubscriptionType)
β β βββ /enum/ # Enums related to this module
βββ /test/ # Test helpers
Create-GraphQL
If you want to move faster you should use create-graphql to simplify the creation of a GraphQL Server
Command
Setup
yarn install
Note: If you do not have mongodb installed, please install it:
brew install mongodb
Develop
yarn watch
Test
yarn test
Or
yarn test:watch
Docker and docker-compose
No needs for installing dependencies or running mongod
in another terminal window
docker-compose build && docker-compose up
Test
docker-compose -f docker-compose.test.yml build && docker-compose -f docker-compose.test.yml up
Production
# first compile the code
yarn build
# run graphql compiled server
yarn start
Flow
yarn flow
Or
flow
REPL server
yarn repl
awesome > const user = await M.User.find()
Yep, await syntax works on the repl, it is awesome, tks @princejwesley (https://gist.github.com/princejwesley/a66d514d86ea174270210561c44b71ba)
Schema
Update your schema
yarn update-schema
Take a look on the Schema