A graphql api where we can store and get information on characters in Outerbanks.
This example is an updated version (2023) of outerbanks-api and it is based on: https://www.apollographql.com/blog/graphql/golang/using-graphql-with-golang.
$ go install github.com/99designs/gqlgen@latest
Add gqlgen
to your project's tools.go
file
$ printf '// +build tools\npackage tools\nimport _ "github.com/99designs/gqlgen"' | gofmt > tools.go
$ go get github.com/kataras/iris/v12@latest
$ go mod tidy -compat=1.20
Start the graphql server
$ go run .
On the editor panel paste:
mutation upsertCharacter($input:CharacterInput!){
upsertCharacter(input:$input) {
name
id
}
}
And in the variables panel below, paste:
{
"input":{
"name": "kataras",
"cliqueType": "POGUES"
}
}
Hit Ctrl+Enter to apply the mutation.
Query:
query character($id:ID!) {
character(id:$id) {
id
name
}
}
Variables:
{
"id":1
}
$ cd graph
$ rm -f graph/schema.resolvers.go
$ touch schema.graphql # make your updates here
$ gqlgen generate