{"_id":"@appliedpiper/graphql-template-contract","name":"@appliedpiper/graphql-template-contract","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@appliedpiper/graphql-template-contract","version":"1.0.0","private":false,"description":"A GraphQL server template built with TypeScript, Apollo Server, and MongoDB.","main":"dist/index.js","types":"dist/index.d.ts","exports":{".":{"types":"./dist/contract.d.ts"}},"keywords":[],"author":{"name":"Eli Scott"},"license":"ISC","dependencies":{"@apollo/server":"^5.0.0","@apollo/utils.keyvaluecache":"^4.0.0","@graphql-tools/load-files":"^7.0.1","@graphql-tools/merge":"^9.1.2","dotenv-flow":"^4.1.0","graphql":"^16.11.0","graphql-tag":"^2.12.6","mongodb":"^6.20.0","zod":"^4.1.12"},"devDependencies":{"@graphql-codegen/cli":"^6.0.1","@graphql-codegen/typescript":"^5.0.2","@graphql-codegen/typescript-resolvers":"^5.1.0","@types/jest":"^30.0.0","@types/node":"^24.9.1","jest":"^30.2.0","mongodb-memory-server":"^10.3.0","ts-jest":"^29.4.6","tsc-alias":"^1.8.16","tsconfig-paths":"^4.2.0","tsx":"^4.21.0","typescript":"^5.9.3"},"scripts":{"build":"tsc && tsc-alias","prebuild":"pnpm run generate","dev":"tsx watch ./src/index.ts","start":"pnpm run build && node ./dist/index.js","test":"jest","generate":"graphql-codegen"},"_id":"@appliedpiper/graphql-template-contract@1.0.0","_integrity":"sha512-JNl2N4KrEPt5oidORp1qTJ9r4TvSbEGPPlKPQ9eSmaDusSNspZa27GUFSIwodoOsVdxSLLz9kWrzwUU93RZ+gQ==","_resolved":"/private/var/folders/gs/4kc_yhv94cq5gvrpkjv638_c0000gn/T/d374b93b5ba1678c840d8745190f0dde/appliedpiper-graphql-template-contract-1.0.0.tgz","_from":"file:appliedpiper-graphql-template-contract-1.0.0.tgz","_nodeVersion":"22.18.0","_npmVersion":"10.9.3","dist":{"integrity":"sha512-JNl2N4KrEPt5oidORp1qTJ9r4TvSbEGPPlKPQ9eSmaDusSNspZa27GUFSIwodoOsVdxSLLz9kWrzwUU93RZ+gQ==","shasum":"aa7d8f0cf561821c8609f286bd3da8e8f30285f4","tarball":"https://registry.npmjs.org/@appliedpiper/graphql-template-contract/-/graphql-template-contract-1.0.0.tgz","fileCount":21,"unpackedSize":18609,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDXyxyR9qqvhEZwuO75TIKaD6zMtgMRBhi0MrrKAP6eygIhAL8vSVGjNgDBGMrqEDOSsQ3s7eHrYtMYwk22RPiElBGK"}]},"_npmUser":{"name":"appliedpiper","email":"scottej1@gmail.com"},"directories":{},"maintainers":[{"name":"appliedpiper","email":"scottej1@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/graphql-template-contract_1.0.0_1770677193269_0.5776263023885284"},"_hasShrinkwrap":false}},"time":{"created":"2026-02-09T22:46:33.116Z","1.0.0":"2026-02-09T22:46:33.429Z","modified":"2026-02-09T22:46:33.660Z"},"maintainers":[{"name":"appliedpiper","email":"scottej1@gmail.com"}],"description":"A GraphQL server template built with TypeScript, Apollo Server, and MongoDB.","keywords":[],"author":{"name":"Eli Scott"},"license":"ISC","readme":"# GraphQL TypeScript Template\r\n\r\nA standalone GraphQL server template built with **TypeScript**, **MongoDB**, and **Apollo Server**, designed for rapid API development. GraphQL Server can be deployed in a local or containerized environment.   \r\n\r\n--- \r\n## Table of Contents\r\n- [Features](#features)\r\n- [Prerequisites](#prerequisites)\r\n- [Getting Started](#getting-started)\r\n- [Configure Environment Variables](#configure-environment-variables)\r\n- [Seeding the Database](#seeding-the-database)\r\n- [Customizing the Schema](#customizing-the-schema)\r\n- [Testing](#testing)\r\n- [Docker](#docker)\r\n- [Contributing](#contributing)\r\n- [License](#license)\r\n\r\n\r\n## Features\r\n- TypeScript-first GraphQL API\r\n- MongoDB as primary data source\r\n- Modular `.graphql` schema files\r\n- Apollo Server context with multiple datasources support\r\n- Custom Scalars (`Date`, `Email`)\r\n- GraphQL Codegen for TypeScript types\r\n- Seed data mutations for users and orders\r\n- Jest tests for resolvers and database operations\r\n- Containerized GraphQL Production and Development builds\r\n\r\n---\r\n\r\n## Prerequisites\r\n\r\n- Node.js >= 18\r\n- pnpm >= 10\r\n- MongoDB instance (local or cloud)\r\n\r\n---\r\n\r\n## Getting Started\r\n\r\nFollow these steps to set up the project locally:\r\n\r\n1. **Install pnpm globally** (if not already installed):\r\n\r\n```bash\r\nnpm install -g pnpm\r\n```\r\n\r\n2. **Clone the Repository**\r\n```bash\r\ngit clone https://github.com/appliedpiper/graphql-ts-template.git\r\ncd graphql-ts-template\r\n```\r\n\r\n3. **Install the Dependencies**\r\n```bash\r\npnpm install\r\n```\r\n\r\n4. **Configure Environment Variables**\r\nUpdate the .env file in the project root to specify the MongoDB URI, Database Name and GraphQL Port\r\n```\r\nDOTENV_CONFIG_QUIET=true\r\nGQL_PORT=4000\r\n#Replace the MONGO_URI with your MongoDB connection string\r\nMONGO_URI=mongodb://localhost:27017\r\nDB_NAME=gql_template\r\n```\r\n\r\n5. **Start the Development Server**\r\n```bash\r\npnpm dev\r\n```\r\nYour server should now be running at http://localhost:4000/graphql (or the port you specified).\r\n\r\n\r\n6. **Seeding the Database**\r\nUse the GraphQL mutation seedDatabase to populate user and orders collections.  Defaults: userCount = 5, orderCount = 10.\r\n```\r\nmutation SeedDatabase($input: SeedInput) {\r\n  seedDatabase(input: $input) {\r\n    ordersInserted\r\n    usersInserted\r\n  }\r\n}\r\n```\r\n\r\nDefine the SeedInput as part of the gql variables\r\n```\r\n  \"variables\": {\r\n    \"input\": {\r\n      \"orderCount\": 10,\r\n      \"userCount\": 20\r\n    }\r\n  }\r\n```\r\n\r\n7. **Execute GQL Queries**\r\nFrom http://localhost:4000/graphql Build a query such as\r\n```\r\nquery USER_QUERY {\r\n  user(name: \"1\") {\r\n    firstName\r\n    lastName\r\n    email\r\n    orders {\r\n      total\r\n      createdAt\r\n    }\r\n  }\r\n}\r\n```\r\n\r\n8.  **Customizing the Schema**\r\nUpdate the schema as desired (/src/schema), creating new types, scalars, queries and mutations.  After you make changes be sure to stop the GraphQL server and run:\r\n\r\n```bash\r\npnpm generate\r\n```\r\n\r\nThis will create the new TypeScript Types from the GraphQL Schema in /src/__generated__/types.ts.  /src/schema/typeDefs.ts imports all sub-schemas.  \r\n\r\nDepending on the size of your project or organizational preference, you may want to organize your schema directory based on feature.  \r\n\r\nEx: \r\n```\r\nsrc/\r\n├─ schema/\r\n│ ├─ user/\r\n│ │ ├─ typeDefs.graphql\r\n│ │ ├─ resolvers.ts\r\n│ ├─ order/\r\n│ │ ├─ typeDefs.graphql\r\n│ │ ├─ resolvers.ts\r\n```\r\n9.  **Testing**\r\nJEST is configured for Typescript.  Example test cases are located in /src/__tests__/*.test.ts.  Tests and coverage report can be executed by running:\r\n\r\n```bash\r\npnpm test\r\n```\r\n\r\n10. **Docker**\r\nTo improve the deployment process I included a Dockerfile and docker-compose.yml to fully containerize a production or development environments.  \r\n\r\n```bash\r\n# Development mode with hot reload\r\ndocker-compose up graphql-dev --build\r\n\r\n# Production mode\r\ndocker-compose up graphql-prod --build\r\n```\r\n\r\n## Contributing\r\n\r\n1. Fork the repository\r\n2. Create a feature branch (git checkout -b feature/my-feature)\r\n3. Commit your changes (git commit -m 'Add new feature')\r\n4. Push to the branch (git push origin feature/my-feature)\r\n5. Open a pull request\r\n\r\n## License\r\nThis project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details.","readmeFilename":"README.md","_rev":"1-e8a07722c2904bddb4e08c6d3596ec81"}