New playground for the node/graphql rewrite
- Duplicate the
env.example
file and rename it.env
- Run
npm install
- Run
npm run dev
- Start you docker container from the berkeleytime repo node branch
http://localhost:5001/graphql
The main concern for typesafety comes from the potential inconsistency between typedefs
(GraphQL SDL) and your actual resolvers. To maintain typesafety, we use GraphQL Code Generation to generate types for schemas, resolvers and more.
To generate types, run npm run generate
Type safety is also set up within modules, see the documentation for more details.
.
├── src # Where your source code lives
│ ├── bootstrap # Bootstrapping and loading of the API dependencies (Express, Apollo, Database, ...)
│ ├── db # Mongo schemas, models and types
│ ├── generated-types # Generated types from codegen
│ ├── modules # Business logic of the app divided by domain (such as User and Catalog)
│ ├── tests # Where all our testing strategy lives
│ ├── utils # Collection of utils function that we use in the project
│ ├── config.ts # Config of the app, sourced by environment variables
│ └── index.ts # Entry point of the API
│
├── jest-mongodb-config.js # Optional if you don't use MongoDB!
├── jest.config.js # Jest configuration
├── docker-compose.yml # Docker compose configuration (Optional !)
├── .env.example # Example of what your .env file should look like
├── .gitignore # Standard gitignore file
└── codegen.ts # Code generation configurations
├── package.json # Node module dependencies
├── README.md # Simple readme file
└── tsconfig.json # TypeScript compiler options
.
├── src
│ └── modules
│ └── user # Module name
│ ├── index.ts # Entrypoint to the module
│ └── generated-types # Generated types from codegen
│ └── module-types.ts # Relevant GraphQL typescript types
│ └── typedefs # Typedefs
│ └── [schema].ts # A typedef for a schema
│ ├── controller.ts # Your crud controller methods
│ ├── fixture.ts # Object used for testing (can ignore)
│ ├── formatter.ts # Formats your db models to your controller/gql models
│ ├── resolver.ts # Your resolver
│ ├── schema.ts # Your gql schemas (and potentially typscript interfaces associated to the schemas)
│ └── service.ts # Business logic of your app
- Run
npm start
- NodeJS and TypeScript
- GraphQL with Apollo Server
- MongoDB Database integrated with Mongoose