apollo-rest-example
Demo of wrapping a REST API Server via Apollo Server.
- Fully type safe
- Uses
@graphql-codegen/typescript-resolversto auto-generate the resolver types based on the Schema Seegraphql-server/codegen.ymlfor configuration
Start REST API Server
cd graphql-server
yarn start # or `yarn watch` for devChanges are only stored in memory, so all data is reset when restarting the server.
You can see all currently stored data via http://localhost:8080/books.
Start Apollo Server
cd graphql-server
yarn start # or `yarn watch` for dev
yarn graphql-generate # generate typings for resolvers based on schemaopen http://localhost:4000/ to see the GraphQL Playground
GraphQL Queries
Get Data
All Books
{
books {
title
author
}
}Get the title of the book at index 2
{
book(id: 2) {
title
}
}Post data
Adds a new book
mutation {
addBook(input: { title: "Another exciting book", author: "Stephen King" }) {
title
author
}
}Put data
Updates an existing book (by index)
mutation {
updateBook(
id: 2
input: { title: "Another exciting book", author: "Stephen King" }
) {
title
author
}
}
Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.
