crdb-graphql

command module
v0.0.0-...-ae7746f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2023 License: MIT Imports: 9 Imported by: 0

README

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

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL