Skip to content

conorheffron/go-graph

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-graph

License: GPL v3

Go

Overview

  • Track to do items with Go & GraphQL.

Quick start build steps

go install github.com/99designs/gqlgen@latest

go mod init go-graph

go get github.com/99designs/gqlgen@v0.17.81

go run github.com/99designs/gqlgen init

go mod tidy

go build .

./go-graph

Should see the following in console:

2025/10/25 17:37:16 connect to http://localhost:8080/ for GraphQL playground

Start Server (without Build Steps)

go run ./server.go  

Go to GraphiQL UI

Sample Mutations & Query (GraphQL format)

query myToDos {
  todos {
    id
    text
    done
  }
}

mutation addToDo {
  createTodo(text: "Learn GraphQL") {
    id
    text
    done
  }
}

mutation addToDo2 {
  createTodo(text: "Shopping") {
    id
    text
    done
  }
}

mutation addToDo3 {
  createTodo(text: "Exercise") {
    id
    text
    done
  }
}

Sample Mutations & Query (curl format)

Muation (Add 'Learn GraphQL' to do)

curl -X POST -H "Content-Type: application/json" \
-d '{"query": "mutation { createTodo(text: \"Learn GraphQL\") { id text done } }"}' \
http://localhost:8080/query

Response

{"data":{"createTodo":{"id":"8053753236064475949","text":"Learn GraphQL","done":false}}}

Muation (Add 'Shopping' to do)

curl -X POST -H "Content-Type: application/json" \
-d '{"query": "mutation { createTodo(text: \"Shopping\") { id text done } }"}' \
http://localhost:8080/query

Response

{"data":{"createTodo":{"id":"3260314713893700176","text":"Shopping","done":false}}}

Query (Get TODOs list)

curl -X POST -H "Content-Type: application/json" \
-d '{"query": "query { todos { id text done } }"}' \                            
http://localhost:8080/query

Response

{"data":{"todos":[{"id":"8053753236064475949","text":"Learn GraphQL","done":false},{"id":"3260314713893700176","text":"Shopping","done":false}]}}

About

This is a small application used track to do items using Go & the GraphQL Playground

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages