Skip to content

Add minimal GraphQL demo service (Apollo Server 4 + Express, in-memory store) - #1

Merged
charles2ke merged 2 commits into
mainfrom
copilot/implement-graphql-backend-service
Aug 27, 2026
Merged

Add minimal GraphQL demo service (Apollo Server 4 + Express, in-memory store)#1
charles2ke merged 2 commits into
mainfrom
copilot/implement-graphql-backend-service

Conversation

Copilot AI commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

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/Post domain, with in-memory storage so it works from a clean checkout without external dependencies.

Changes

  • Project setuppackage.json (Node ESM, @apollo/server 4, express, graphql, cors), lockfile, .gitignore. Scripts: start, dev (node --watch), test.
  • Service (src/)
    • index.js — Express bootstrap, /graphql endpoint (port 4000, PORT override) plus a /health probe.
    • server.js — Apollo Server factory, split from the HTTP bootstrap so tests can execute operations without binding a port.
    • schema.jsUser, Post; queries users, user(id), posts, post(id); mutations createUser, createPost.
    • resolvers.js — includes nested User.posts / Post.author; createPost rejects unknown authorId with BAD_USER_INPUT since 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.
  • Tests (test/graphql.test.js) — built-in node:test runner, no extra dev dependencies; each test gets a fresh store.
  • README — stack, structure, install, run, endpoint URL, example queries/mutations and a curl example.

Example

curl http://localhost:4000/graphql -H 'Content-Type: application/json' \
  -d '{"query":"{ users { id name posts { title } } }"}'
{"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.

Co-authored-by: charles2ke <6725706+charles2ke@users.noreply.github.com>
@charles2ke
charles2ke marked this pull request as ready for review August 27, 2026 09:20
@charles2ke
charles2ke requested a lite review from Copilot August 27, 2026 09:20
Copilot AI changed the title [WIP] Add minimal backend service with GraphQL API Add minimal GraphQL demo service (Apollo Server 4 + Express, in-memory store) Aug 27, 2026
Copilot AI requested a review from charles2ke August 27, 2026 09:22
@charles2ke
charles2ke merged commit 85f8d0b into main Aug 27, 2026
1 check passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 /graphql and /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.

Comment thread package.json
Comment on lines +7 to +9
"engines": {
"node": ">=18"
},

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

Comment thread package.json
Comment on lines +22 to +26
"dependencies": {
"@apollo/server": "^4.11.3",
"cors": "^2.8.5",
"express": "^4.21.2",
"graphql": "^16.10.0"

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

Comment thread README.md
Comment on lines +11 to +12
- [Node.js](https://nodejs.org/) 18+ (ES modules)
- [Apollo Server 4](https://www.apollographql.com/docs/apollo-server/) on [Express](https://expressjs.com/)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

Comment thread README.md
Comment on lines +49 to +50
Opening the GraphQL endpoint in a browser loads the Apollo Sandbox, where you can
explore the schema and run the operations below.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

@charles2ke

Copy link
Copy Markdown
Owner

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants