Add minimal GraphQL demo service (Apollo Server 4 + Express, in-memory store) - #1
Conversation
Co-authored-by: charles2ke <6725706+charles2ke@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
The declared Node.js support range and dependency choices don’t match the current test/runtime requirements (Node engine mismatch; Apollo Server v4 EOL), and the README contains environment-dependent behavior presented as unconditional.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds a minimal Node.js backend service exposing a GraphQL API (User/Post) using Apollo Server on Express, backed by an in-memory store, with tests and documentation to support local development and verification.
Changes:
- Introduces GraphQL schema + resolvers + in-memory store for a small demo domain.
- Adds an Express HTTP bootstrap exposing
/graphqland/health. - Adds
node:test-based API tests and a comprehensive README with usage examples.
File summaries
| File | Description |
|---|---|
| test/graphql.test.js | Exercises queries/mutations against the Apollo schema using executeOperation. |
| src/server.js | Exposes an ApolloServer factory for reuse by HTTP bootstrap and tests. |
| src/schema.js | Defines the User/Post GraphQL schema and operations. |
| src/resolvers.js | Implements query/mutation and field resolvers backed by the store. |
| src/index.js | Boots an Express server, wires Apollo middleware, adds /health. |
| src/data/store.js | Implements a tiny in-memory “DB-like” store with seed data. |
| README.md | Documents setup, endpoints, and example operations. |
| package.json | Defines runtime scripts, engines, and dependencies. |
| package-lock.json | Locks dependency graph for reproducible installs. |
| .gitignore | Ignores Node/artifact files (node_modules, coverage, env files). |
Review details
- Files reviewed: 8/10 changed files
- Comments generated: 4
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| "engines": { | ||
| "node": ">=18" | ||
| }, |
There was a problem hiding this comment.
@copilot Fix the code for this review comment.
When a review comment includes a suggested change, apply the suggestion exactly.
Do not make changes beyond what is described in the linked review comment.
| "dependencies": { | ||
| "@apollo/server": "^4.11.3", | ||
| "cors": "^2.8.5", | ||
| "express": "^4.21.2", | ||
| "graphql": "^16.10.0" |
There was a problem hiding this comment.
@copilot Fix the code for this review comment.
When a review comment includes a suggested change, apply the suggestion exactly.
Do not make changes beyond what is described in the linked review comment.
| - [Node.js](https://nodejs.org/) 18+ (ES modules) | ||
| - [Apollo Server 4](https://www.apollographql.com/docs/apollo-server/) on [Express](https://expressjs.com/) |
There was a problem hiding this comment.
@copilot Fix the code for this review comment.
When a review comment includes a suggested change, apply the suggestion exactly.
Do not make changes beyond what is described in the linked review comment.
| Opening the GraphQL endpoint in a browser loads the Apollo Sandbox, where you can | ||
| explore the schema and run the operations below. |
There was a problem hiding this comment.
@copilot Fix the code for this review comment.
When a review comment includes a suggested change, apply the suggestion exactly.
Do not make changes beyond what is described in the linked review comment.
|
@copilot Fix the code for all comments in this review thread. When a review comment includes a suggested change, apply the suggestion exactly. Do not make changes beyond what is described in the linked review thread. |
The repository contained only a LICENSE and a one-line README. This adds a runnable backend service exposing a GraphQL API over a small
User/Postdomain, with in-memory storage so it works from a clean checkout without external dependencies.Changes
package.json(Node ESM,@apollo/server4,express,graphql,cors), lockfile,.gitignore. Scripts:start,dev(node --watch),test.src/)index.js— Express bootstrap,/graphqlendpoint (port4000,PORToverride) plus a/healthprobe.server.js— Apollo Server factory, split from the HTTP bootstrap so tests can execute operations without binding a port.schema.js—User,Post; queriesusers,user(id),posts,post(id); mutationscreateUser,createPost.resolvers.js— includes nestedUser.posts/Post.author;createPostrejects unknownauthorIdwithBAD_USER_INPUTsince referential integrity isn't enforced by the store.data/store.js— in-memory store with seed data, exposing a database-like API and injected via the GraphQL context, so it can be swapped for a persistent backend without touching resolvers.test/graphql.test.js) — built-innode:testrunner, no extra dev dependencies; each test gets a fresh store.Example
{"data":{"users":[{"id":"1","name":"Ada Lovelace","posts":[{"title":"Hello GraphQL"}]}, ...]}}Data resets to seed state on every restart, which is intentional for a demo service.