The Wayback Machine - https://web.archive.org/web/20200914001642/https://github.com/rangle/apollo-rest-example
Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 

README.md

apollo-rest-example

Demo of wrapping a REST API Server via Apollo Server.

Start REST API Server

cd graphql-server
yarn start # or `yarn watch` for dev

Changes 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 schema

open 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
  }
}

About

Apollo Rest API Server Adaptor Example

Resources

Releases

No releases published

Packages

No packages published
You can’t perform that action at this time.