Skip to content

mhallin/juniper-example-todo-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple Rust, GraphQL, and SQLite example

Build Status

This is a small repository connected to Juniper that serves an endpoint similar to Todo-Backend but using GraphQL instead. It uses SQLite as the database with Diesel as the ORM, and Iron as the web server.

Running

Make sure you've got Rust installed, then run the following:

# If you haven't got the Diesel CLI installed already:
cargo install --no-default-features --features sqlite diesel_cli

# Clone this repository
git clone https://github.com/mhallin/juniper-example-todo-backend.git

# Create an empty test database
diesel migration run

# Build and run the server
cargo run

If all of that succeeded, you should have a GraphiQL interface running at http://localhost:8080.

Interacting

Here are some example queries you can run through GraphiQL:

# Create a new todo item and get the ID back
mutation {
  addTodo(title: "Write documentation", completed: false) {
    id
    title
    completed
  }
}
# List all todo items in the database
{
  todoItems {
    id
    title
    completed
  }
}
# Mark an item as completed
mutation {
  updateTodo(id: 1, completed: true) {
    id
  }
}

You can also check out the documentation in the "Docs" pane of GraphiQL. This view is automatically generated from the documentation strings in the source. Check out src/schema.rs to see how it looks.

About

Simple example how to use GraphQL with SQLite, Diesel, and Iron

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages