Windsurf prompt to build a GraphQL API
This prompt has Cascade stand up an Apollo GraphQL server with cursor pagination, dataloaders, and typed error payloads, then prove it works by firing an introspection query from the Windsurf terminal. You end up with a schema file, a resolvers directory, and a written list of nullability decisions to review.
Last updated
Build a TypeScript GraphQL API with Apollo Server backed by {{database}}. Schema: a {{resource}} type, a query for one {{resource}} by id, a cursor-paginated list query, and create, update, delete mutations returning a payload with a userErrors field instead of throwing. Put SDL in src/schema.graphql, resolvers under src/resolvers/, and a dataloader per relation to prevent N+1 lookups. Validate input at the resolver boundary and map {{database}} failures to typed errors. Ask before installing packages. Then start the server from the Windsurf terminal and run an introspection query plus one create-then-fetch round trip to prove the wiring. Finish by listing every file you created and the nullability decisions you made so I can review them.Customize it
Runs in your browser. Nothing you type here is sent anywhere.
Build a TypeScript GraphQL API with Apollo Server backed by PostgreSQL. Schema: a users type, a query for one users by id, a cursor-paginated list query, and create, update, delete mutations returning a payload with a userErrors field instead of throwing. Put SDL in src/schema.graphql, resolvers under src/resolvers/, and a dataloader per relation to prevent N+1 lookups. Validate input at the resolver boundary and map PostgreSQL failures to typed errors. Ask before installing packages. Then start the server from the Windsurf terminal and run an introspection query plus one create-then-fetch round trip to prove the wiring. Finish by listing every file you created and the nullability decisions you made so I can review them.
Same task in other tools
Questions about this prompt
Will Cascade actually execute queries against the running server?
Yes, once you approve the terminal commands it can start the server and curl the endpoint. The create-then-fetch round trip is in the prompt so wiring failures surface immediately rather than on your first manual test.
How do I adapt this for an existing REST codebase?
Tell Cascade to mount the GraphQL endpoint alongside the current routes and reuse your existing data access layer inside resolvers. Drop the {{database}} token and point it at your repository modules instead.
Responses are slow on list queries even though dataloaders exist. Why?
A resolver is probably fetching inside a loop with direct model calls, which reintroduces N+1 around the loader. Ask Cascade to grep src/resolvers/ for direct database calls and route every relation through its loader.