Skip to content

Commit

Permalink
Merge pull request #1617 from 99designs/update-docs-for-go1.17
Browse files Browse the repository at this point in the history
Update docs for getting started
  • Loading branch information
mtibben committed Sep 15, 2021
2 parents 41d6926 + 5c52f27 commit 7d549d6
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 15 deletions.
37 changes: 30 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,44 @@

## What is gqlgen?

[gqlgen](https://github.com/99designs/gqlgen) is a Go library for building GraphQL servers without any fuss.<br/>
[gqlgen](https://github.com/99designs/gqlgen) is a Go library for building GraphQL servers without any fuss.<br/>

- **gqlgen is based on a Schema first approach** — You get to Define your API using the GraphQL [Schema Definition Language](http://graphql.org/learn/schema/).
- **gqlgen prioritizes Type safety** — You should never see `map[string]interface{}` here.
- **gqlgen enables Codegen** — We generate the boring bits, so you can focus on building your app quickly.

Still not convinced enough to use **gqlgen**? Compare **gqlgen** with other Go graphql [implementations](https://gqlgen.com/feature-comparison/)

## Getting Started
- To install gqlgen run the command `go get github.com/99designs/gqlgen` in your project directory.<br/>
- You could initialize a new project using the recommended folder structure by running this command `go run github.com/99designs/gqlgen init`.
## Quick start
```shell
# Initialise a new go module
mkdir example
cd example
go mod init gqlgen.com/example

You could find a more comprehensive guide to help you get started [here](https://gqlgen.com/getting-started/).<br/>
We also have a couple of real-world [examples](https://github.com/99designs/gqlgen/tree/master/example) that show how to GraphQL applications with **gqlgen** seamlessly,
You can see these [examples](https://github.com/99designs/gqlgen/tree/master/example) here or visit [godoc](https://godoc.org/github.com/99designs/gqlgen).
# Add github.com/99designs/gqlgen to your project's tools.go
cat <<EOD > tools.go
// +build tools
package tools
import (
_ "github.com/99designs/gqlgen"
)
EOD
go mod tidy

# Initialise gqlgen config
go run github.com/99designs/gqlgen init

# Start the graphql server
go run server.go
```

More help to get started:
- [Getting started guide](https://gqlgen.com/getting-started/) - a comprehensive guide to help you get started
- [Real-world examples](https://github.com/99designs/gqlgen/tree/master/example) show how to create GraphQL applications
- [Reference docs](https://pkg.go.dev/github.com/99designs/gqlgen) for the APIs

## Reporting Issues

Expand Down
30 changes: 22 additions & 8 deletions docs/content/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,33 @@ You can find the finished code for this tutorial [here](https://github.com/vekta

Create a directory for your project, and initialise it as a Go Module:

```sh
$ mkdir gqlgen-todos
$ cd gqlgen-todos
$ go mod init github.com/[username]/gqlgen-todos
$ go get github.com/99designs/gqlgen
```shell
mkdir gqlgen-todos
cd gqlgen-todos
go mod init github.com/[username]/gqlgen-todos
```

Next, add the gqlgen tool as a dependency [using your project's tools.go](https://github.com/golang/go/wiki/Modules#how-can-i-track-tool-dependencies-for-a-module)

```shell
cat <<EOD > tools.go
// +build tools
package tools
import (
_ "github.com/99designs/gqlgen"
)
EOD
go mod tidy
```

## Building the server

### Create the project skeleton

```bash
$ go run github.com/99designs/gqlgen init
```shell
go run github.com/99designs/gqlgen init
```

This will create our suggested package layout. You can modify these paths in gqlgen.yml if you need to.
Expand Down Expand Up @@ -86,7 +100,7 @@ type Mutation {
### Implement the resolvers

When executed, gqlgen's `generate` command compares the schema file (`graph/schema.graphqls`) with the models `graph/model/*`, and, wherever it
can, it will bind directly to the model. That was done alread when `init` was run. We'll edit the schema later in the tutorial, but for now, let's look at what was generated already.
can, it will bind directly to the model. That was done alread when `init` was run. We'll edit the schema later in the tutorial, but for now, let's look at what was generated already.

If we take a look in `graph/schema.resolvers.go` we will see all the times that gqlgen couldn't match them up. For us
it was twice:
Expand Down

0 comments on commit 7d549d6

Please sign in to comment.