iris/_examples/graphql/schema-first
dependabot[bot] 9e2af4eb7a
Bump golang.org/x/net in /_examples/graphql/schema-first (#2070)
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.5.0 to 0.7.0.
- [Release notes](https://github.com/golang/net/releases)
- [Commits](https://github.com/golang/net/compare/v0.5.0...v0.7.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-19 21:13:21 +02:00
..
graph add graphql example 2023-02-07 03:01:24 +02:00
go.mod Bump golang.org/x/net in /_examples/graphql/schema-first (#2070) 2023-02-19 21:13:21 +02:00
go.sum Bump golang.org/x/net in /_examples/graphql/schema-first (#2070) 2023-02-19 21:13:21 +02:00
gqlgen.yml add graphql example 2023-02-07 03:01:24 +02:00
README.md add graphql example 2023-02-07 03:01:24 +02:00
server.go add graphql example 2023-02-07 03:01:24 +02:00
tools.go add graphql example 2023-02-07 03:01:24 +02:00

outerbanks-api

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.

Getting Started

$ 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@master
$ go mod tidy -compat=1.19

Start the graphql server

$ go run .

Mutation

Open http://localhost:8080

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:

query character($id:ID!) {
  character(id:$id) {
    id
    name
  }
}

Variables:

{
 "id":1
}

Re-generate code

$ cd graph
$ rm -f graph/schema.resolvers.go
$ touch schema.graphql # make your updates here
$ gqlgen generate