10. 3 parts of a GraphQL server
1. Structure: The GraphQL schema
2. Behaviour: Resolver functions
3. Network Layer: Network, Middleware, …
11. 1) The GraphQL Schema
• Strongly typed & written in GraphQL Schema Definition
Language (SDL)
• Defines API capabilities ( = contract for client-server
communication)
• Special root types: Query, Mutation, Subscription
@nikolasburk
14. 2) Resolver functions
• Concrete implementation of the API
• One resolver function per field in SDL schema
• Query execution: Invoke resolvers for all fields in query
@nikolasburk
18. …putting it all together
1) SCHEMA
2) RESOLVERS
3) NETWORK LAYER
x
19. Building a clone of the Medium API
…from scratch
• Queries
• Retrieve a list of all posts (or filter for `title` or `content`)
• Retrieve a single post by its `id`
• Mutations
• Create a new draft
• Publish a draft
• Delete any post by its `id` (published or draft)
@nikolasburk
21. Steps
@nikolasburk
Step 0: Minimal GraphQL server
Step 1: Extend API with query arguments
Step 2: Complete API operations
Step 3: Add database layer with Prisma and Prisma bindings
Step 4: Complete API operations against the database
23. Get the code
@nikolasburk
$ # clone the repo
$ git clone https://github.com/nikolasburk/amsjs-workshop.git
$ cd amsjs-workshop
$
$ # navigate to the initial setup
$ git checkout step0