← All Learning Paths

GraphQL API Developer

Design GraphQL APIs that stay fast: resolvers, N+1 batching, cursor pagination, typed codegen, and protecting the server from deeply nested query bombs.

roleintermediate11 nodes15.17h total

Path overview

GraphQL 的灵活性既是生产力也是攻击面。本路径从解析器与 N+1 查询问题出发,横跨 JavaScript、Python、Go、Rust 四种服务端栈的分页与类型化实践,最终落到查询深度防御与真实案例复盘。

GraphQL flexibility is both productivity and attack surface. This path covers resolvers, N+1 batching, cursor pagination, and typed codegen across four server stacks, ending with query-bomb defenses and a case study.

  1. Read "Apollo Server"'s documented surface around "new ApolloServer new ApolloServer(config: ApolloServerOptions<TContext>): ApolloServer", then build a minimal endpoint and log the response.

    Completion criteria: Run a request against "Apollo Server", paste the response, and add one deliberately invalid call with its error.

    Next step: GraphQL Request Cursor Pagination

    ⏱ 1h

  2. Execute "GraphQL Request Cursor Pagination", change one constant, and describe how the output diverges from "Fetch paginated GraphQL connections with graphql-request, following cursor edges and".

    Prerequisites: Apollo Server

    Completion criteria: Attach the terminal transcript for "GraphQL Request Cursor Pagination": command, exit code, and the printed result you used to confirm "Fetch paginated GraphQL connections with graphql-request, following cursor edges and".

    Next step: GraphQL Codegen Typed Document Nodes

    ⏱ 0.75h

  3. Run the graphql snippet "GraphQL Codegen Typed Document Nodes", capture stdout, and show which line demonstrates the documented behavior: "Generate fully typed GraphQL document nodes with codegen, so queries, variables, and result".

    Prerequisites: GraphQL Request Cursor Pagination

    Completion criteria: Change one constant in "GraphQL Codegen Typed Document Nodes", rerun, and attach both stdout captures plus a one-line diff explaining what moved.

    Next step: Strawberry GraphQL FastAPI Resolvers

    ⏱ 0.75h

  4. Adapt "Strawberry GraphQL FastAPI Resolvers" to a second input and compare the new output with the behavior described in "Define a GraphQL schema with Strawberry on FastAPI, writing typed resolvers for queries and".

    Prerequisites: GraphQL Codegen Typed Document Nodes

    Completion criteria: Paste the command, the exit code, and the output line matching "Define a GraphQL schema with Strawberry on FastAPI, writing typed resolvers for queries and"; then show a second run with a changed parameter.

    Next step: Gqlgen GraphQL Resolver Cursor Pagination

    ⏱ 0.75h

  5. Execute "Gqlgen GraphQL Resolver Cursor Pagination", change one constant, and describe how the output diverges from "Implement Relay-style cursor pagination with gqlgen resolvers, resolving edges and pageInfo".

    Prerequisites: Strawberry GraphQL FastAPI Resolvers

    Completion criteria: Save two runs of "Gqlgen GraphQL Resolver Cursor Pagination" side by side — the original input and one changed value — and annotate the line where the output diverges.

    Next step: GraphQL Client Typed Queries Rust

    ⏱ 0.75h

  6. Run the graphql snippet "GraphQL Client Typed Queries Rust", capture stdout, and show which line demonstrates the documented behavior: "Execute GraphQL queries from Rust with graphql-client, deriving response types from the".

    Prerequisites: Gqlgen GraphQL Resolver Cursor Pagination

    Completion criteria: Attach the terminal transcript for "GraphQL Client Typed Queries Rust": command, exit code, and the printed result you used to confirm "Execute GraphQL queries from Rust with graphql-client, deriving response types from the".

    Next step: GraphQL Yoga

    ⏱ 0.75h

  7. Read "GraphQL Yoga"'s documented surface around "createYoga createYoga(options: YogaServerOptions): YogaServerInstance", then build a minimal endpoint and log the response.

    Prerequisites: GraphQL Client Typed Queries Rust

    Completion criteria: Run a request against "GraphQL Yoga", paste the response, and add one deliberately invalid call with its error.

    Next step: Express + Prisma GraphQL Server

    ⏱ 1h

  8. Map "Express + Prisma GraphQL Server"'s Express, Prisma, GraphQL, TypeScript components to responsibilities and name one trade-off from "DataLoader batching eliminates N+1 queries with automatic request-scoped caching".

    Completion criteria: List each Express, Prisma, GraphQL, TypeScript component of "Express + Prisma GraphQL Server", its responsibility, and one trade-off, citing "DataLoader batching eliminates N+1 queries with automatic request-scoped caching".

    Next step: Apollo GraphQL Server

    ⏱ 1.5h

  9. Stand up "Apollo GraphQL Server" from its CLI, then modify "npm create @apollo/server@latest my-graphql-api" and show the documented behavior still holds.

    Prerequisites: Express + Prisma GraphQL Server

    Completion criteria: Run "Apollo GraphQL Server" once before and once after your modification and paste both outputs with the entry point unchanged.

    Next step: Check GraphQL Field Selection Against a Allowlist

    ⏱ 1.5h

  10. Build "Check GraphQL Field Selection Against a Allowlist" for graphql code and verify {selected:[id,name,ssn],violations:[not-allowed:ssn]} against both samples.

    Prerequisites: Apollo GraphQL Server

    Completion criteria: Submit a solution for "GraphQL API Developer" that passes both samples ({query:{ user { id name ssn } },allowedFields:[id,name]} to {selected:[id,name,ssn],violations:[not-allowed:ssn]}) and attach the failing case you fixed.

    Next step: Capstone: GraphQL API Developer

    ⏱ 0.42h

  11. Deliver the "Build a GraphQL Blog API with DataLoader" blueprint with "Schema-first design" working and "Resolvers and context" recorded as evidence.

    Prerequisites: Apollo GraphQL Server, Check GraphQL Field Selection Against a Allowlist

    Completion criteria: Deliver "Schema-first design" and paste the test output where the acceptance test passes; include the test name and command.

    Next step: Run the capstone's tests, publish the repository, and demo it to a reviewer.

    ⏱ 4h