crdb-grpc
A barebones example of accessing CockroachDB via GraphQL
Dependencies
Running locally
Create a cluster
$ cockroach start-single-node \
--listen-addr=localhost:26257 \
--http-addr=localhost:8080 \
--insecure
Create a table
$ cockroach sql --insecure < create.sql
Start the server
$ go run main.go
Requests
Fetch all todos
{
todos {
id
title
}
}
Fetch one todo
{
todo(id: "8da8291c-5985-41c9-8069-0de865dd20d7") {
title
}
}
Create a todo
mutation CreateTodo($todo: TodoInput!) {
createTodo(todo: $todo) {
id
title
}
}
{
"todo": {
"title": "todo d"
}
}
Delete a todo
mutation DeleteTodo($id: ID!) {
deleteTodo(id: $id)
}
{
"id": "8da8291c-5985-41c9-8069-0de865dd20d7"
}