This is a quickstart project for gqlgen.
git clone https://github.com/meinto/gqlgen-starter.git
cd gqlgen-starter
go run github.com/99designs/gqlgen
go run server/server.go
Open localhost:8080 and copy-paste the query or mutation
query {
hello(name: "Lars")
}
mutation {
foo {
bar
}
}
The project structure is like follows:
/schema # folder for all your schemas
query.gql # all your queries go here
mutation.gql # all your mutations go here
other.gql # place your types in seperate files
/resolver # resolver package
resolver.go # root resolver
other.go # place other resolvers in seperate files
/model # model package
genereated.go # all generated models (don't edit this file)
customModel.go # place all models which you want to define by your own in seperate model files
# don't forget to define this in the config: https://gqlgen.com/config/
/server
server.go # your server
/graph
/generated
generated.go # generated graphql (don't edit this file)
- Now write your types, queries & mutations,
- generate the graphql:
go run github.com/99designs/gqlgen
, - implement the resolvers
- and start your server:
go run server/server.go
. - Have fun! :)
Build your graphql as docker container:
docker build -t gql-server .
docker run -p 8080:8080 gql-server