Members
(constant) createServer
Apollo Server initialization. The server takes the type definitions and resolvers we defined.
(constant) partSchema
Mongoose Schema for the Part model (Computer Parts). This represents a product in our computer parts shop.
- Source:
(constant) resolvers
GraphQL Resolvers. Resolvers define the logic for fetching the data for each field in the schema. They interact with our data source (Mongoose/MongoDB).
- Source:
(constant) startServer
Start the standalone server. In a micro-service architecture, the port is usually configurable via environment variables.
(constant) typeDefs
GraphQL Type Definitions (Schema). We read the schema from a dedicated .graphql file for better readability and syntax highlighting.
Methods
(async) connectDB(uriopt)
Connects to the MongoDB database using the URI provided in environment variables. This is a standard way to handle database connections in a Node.js micro-service.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
uri |
string |
<optional> |
Optional MongoDB URI to override the default one. |