Project Workshop — Job Board — GraphQL Layer
This is a portfolio submission, not a copy-and-run tutorial. A reviewer must be able to clone it, configure it without guessing, execute the critical path, observe a deliberate failure, run the tests, and understand the most important…
- What you are building
- Architecture
- Acceptance criteria
- Suggested repository structure
- Build plan: vertical slices
Graphene-Django · Relay · DataLoader · Channels
Expected effort: 4–7 focused hours · Minimum meaningful tests: 12What you are building
This is a portfolio submission, not a copy-and-run tutorial. A reviewer must be able to clone it, configure it without guessing, execute the critical path, observe a deliberate failure, run the tests, and understand the most important design decision from the README.
Architecture
Critical interaction
Ownership table
| Boundary | Owns | Must not own |
|---|---|---|
| Interface | Parsing, protocol validation, identity extraction, status or presentation mapping | Core business invariants |
| Application/domain | Authorization inputs, state transitions, orchestration, transaction intent | Framework globals or raw transport objects |
| Repository/gateway | One persistence or external protocol, bounded retries, error translation | Product policy |
| Background/UI projection | Recoverable derived state and delivery progress | Hidden authoritative truth |
| Operations | Configuration, health, deployment, telemetry, recovery | Business decisions encoded only in dashboards |
Acceptance criteria
| ID | Required behavior | Evidence |
|---|---|---|
| AC-1.1 | JWT in Authorization header + context middleware produces the specified behavior inside Auth & pagination | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-1.2 | field-level permissions produces the specified behavior inside Auth & pagination | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-1.3 | Relay Connection: edges/node/cursor/pageInfo produces the specified behavior inside Auth & pagination | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-1.4 | cursor-based pagination with DjangoFilterConnectionField produces the specified behavior inside Auth & pagination | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-2.1 | query depth limiting produces the specified behavior inside Security | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-2.2 | query complexity scoring produces the specified behavior inside Security | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-2.3 | introspection disabled in production produces the specified behavior inside Security | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-2.4 | rate limiting on GraphQL endpoint produces the specified behavior inside Security | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-2.5 | SQL injection via inputs produces the specified behavior inside Security | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-3.1 | Channels WebSocket GraphQL transport produces the specified behavior inside Subscriptions & error semantics | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-3.2 | subscribe/next/error/complete lifecycle produces the specified behavior inside Subscriptions & error semantics | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-3.3 | partial data plus errors and error paths produces the specified behavior inside Subscriptions & error semantics | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-3.4 | custom error extensions and stable codes produces the specified behavior inside Subscriptions & error semantics | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-3.5 | persisted query hashes and allowlists produces the specified behavior inside Subscriptions & error semantics | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
Suggested repository structure
1project/2├── manage.py3├── config/{settings,urls,asgi,celery}.py4├── domain/5│ ├── models.py6│ ├── services.py7│ ├── selectors.py8│ ├── serializers-or-schema.py9│ ├── views-or-resolvers.py10│ ├── permissions.py11│ ├── tasks.py12│ └── consumers.py13├── templates/14├── tests/{unit,api,integration}/15├── pyproject.toml16└── compose.yamlBuild plan: vertical slices
| Milestone | Capability | First implementation | Exit condition |
|---|---|---|---|
| 1 | Auth & pagination | JWT in Authorization header + context middleware; field-level permissions; Relay Connection: edges/node/cursor/pageInfo | Demonstration plus focused tests |
| 2 | Security | query depth limiting; query complexity scoring; introspection disabled in production | Demonstration plus focused tests |
| 3 | Subscriptions & error semantics | Channels WebSocket GraphQL transport; subscribe/next/error/complete lifecycle; partial data plus errors and error paths | Demonstration plus focused tests |
| 4 | Hardening and delivery | Security, recovery, telemetry, performance, documentation | Full acceptance suite and recorded demonstration |
For each milestone, first create a failing acceptance test or a reproducible command. Implement the thinnest path to an observable result, add the nearest durable invariant, inject one expected failure, and refactor only after evidence protects the behavior.
Reference vertical slice
1def estimate_cost(field, child_cost: int, args: dict) -> int:2 if field.name in {"posts", "reviews", "edges"}:3 requested = min(int(args.get("first", 20)), 100)4 return 1 + requested * child_cost5 return 1 + child_cost6
7def authorize_post(root, info):8 user = info.context.user9 if not user.is_authenticated:10 raise GraphQLError("authentication required", extensions={"code": "UNAUTHENTICATED"})11 if root.is_private and root.author_id != user.id:12 raise GraphQLError("forbidden", extensions={"code": "FORBIDDEN"})Expected result
1Operations above the configured cost are rejected before execution; private fields enforce request-scoped identity.Code reading
| Line | Code | Explanation |
|---|---|---|
| 1 | def estimate_cost(field, child_cost: int, args: dict) -> int: | Defines a function; its parameters form the explicit input boundary. |
| 2 | if field.name in {"posts", "reviews", "edges"}: | Evaluates the condition and enters this branch only when it is truthy. |
| 3 | requested = min(int(args.get("first", 20)), 100) | Computes or receives a value and binds it for the next step; the referenced object remains separate from the name. |
| 4 | return 1 + requested * child_cost | Returns the observable result to the caller and ends this invocation. |
| 5 | return 1 + child_cost | Returns the observable result to the caller and ends this invocation. |
| 7 | def authorize_post(root, info): | Defines a function; its parameters form the explicit input boundary. |
| 8 | user = info.context.user | Computes or receives a value and binds it for the next step; the referenced object remains separate from the name. |
| 9 | if not user.is_authenticated: | Evaluates the condition and enters this branch only when it is truthy. |
| 10 | raise GraphQLError("authentication required", extensions={"code": "UNAUTHENTICATED"}) | Stops the happy path with a deliberate exception carrying the boundary failure. |
| 11 | if root.is_private and root.author_id != user.id: | Evaluates the condition and enters this branch only when it is truthy. |
| 12 | raise GraphQLError("forbidden", extensions={"code": "FORBIDDEN"}) | Stops the happy path with a deliberate exception carrying the boundary failure. |
Risk register
| Area | Failure to reproduce | Required design response |
|---|---|---|
| Auth & pagination | Automatic model exposure can leak internal fields or create expensive default queries. | Whitelist exposed fields and write explicit mutation validation. |
| Security | Escaping by hand or trusting an enum-like string in a generic raw fragment creates bypasses and often misses second-order stored values. | Use ORM filters or parameterized SQL, allowlist sort/filter operators, bound regex/search complexity, and apply least-privilege database roles. |
| Subscriptions & error semantics | Returning stack traces leaks internals, and authorizing only the initial connection can expose later events after membership changes. | Use stable error extension codes, authorize at subscribe and event time, and cap subscription lifetime and fan-out. |
Engineering checklist for this stack
- To do: authenticate before object lookup where possible
- To do: authorize the action and object server-side
- To do: keep transactions in the application service
- To do: bound request, response, and query work
- To do: map typed domain failures to stable protocol errors
Test strategy
Implement at least 12 meaningful cases. A long list of shallow happy-path tests does not satisfy the requirement.
| Risk class | Minimum | Examples |
|---|---|---|
| Happy path and contract | 2 | Correct output, status/schema, durable state |
| Validation and boundaries | 2 | Empty, malformed, extreme, unsupported transition |
| Authorization or trust boundary | 1 | Missing identity, wrong tenant/role, injection or unsafe content |
| Failure and recovery | 2 | Timeout, retry, rollback, reconnect, dependency outage |
| Duplicate or concurrency | 1 | Same identity twice, racing update, redelivery |
| Performance and operations | 4 | Query bound, lag, p95, resource limit, telemetry |
Representative test scaffold
1def test_private_field_requires_owner(graphql_client, user, other_user, private_post):2 graphql_client.force_login(other_user)3 response = graphql_client.execute(4 "query($id: ID!) { post(id: $id) { id privateNotes } }",5 variables={"id": str(private_post.id)},6 )7 assert response["data"]["post"]["privateNotes"] is None8 assert response["errors"][0]["extensions"]["code"] == "FORBIDDEN"Failure drills
- Stop the primary external dependency during the critical path. Capture the failure, cleanup, telemetry, and recovery.
- Repeat the same operation with the same stable identity. Prove one logical outcome or document why repetition is forbidden.
- Crash after durable state changes but before the response, acknowledgement, or projection. Re-run and reconcile.
- Submit the largest supported input and one slightly larger input.
- Remove one permission and prove denial without state change or information leakage.
- Roll back the change or restore the dependency, then run a smoke test and reconciliation check.
Performance experiment
State the dataset, payload distribution, concurrency, rate, duration, cache state, and resource limits before measuring. Publish p50, p95, p99, throughput, error rate, and the technology-specific correctness signal such as query count, consumer lag, duplicate effects, rendered updates, token cost, or recall. Change one variable at a time and retain raw output.
Submission package
- Complete source with a locked/reproducible environment.
- README.md with problem, architecture, setup, commands, configuration, assumptions, and trade-offs.
- Acceptance and risk-focused tests with a short explanation of what mocks intentionally do not cover.
- One design record explaining the most consequential choice and a rejected alternative.
- Security notes, sample non-secret configuration, and cleanup commands.
- A demonstration record: terminal transcript, screenshots, trace, query plan, or metrics dashboard.
- A 5–8 minute walkthrough following input → validation → state → failure → evidence.
Grading rubric
| Dimension | Weight | Full-credit evidence |
|---|---|---|
| Product behavior | 25 | Acceptance criteria pass through real public boundaries |
| Architecture and ownership | 20 | Responsibilities and state authority are explicit |
| Tests and recovery | 20 | Important negative, duplicate, concurrent, and outage cases pass |
| Security and data correctness | 15 | Least privilege, validation, constraints, and secret handling are demonstrated |
| Performance and operations | 10 | Reproducible measurement, useful telemetry, and rollback/recovery |
| Documentation and explanation | 10 | A new reviewer can reproduce and defend the result |
Mastery check
How well can you recall this?
Finished this lesson?