Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Getting Started Documentation — No Binary Approach #416

Merged
merged 10 commits into from
Nov 28, 2018

Conversation

mathewbyrne
Copy link
Contributor

Addresses #408 — this is a set of improvements to the getting started documentation. The main change is deprecating using a global binary, and moving to always using dep to ensure users have a consistent version.

#415 discusses the whys for this approach.

docs/content/getting-started.md Show resolved Hide resolved
docs/content/getting-started.md Show resolved Hide resolved
At the top of our resolvers.go a go generate command was added that looks like this:
```go
//go:generate gorunpkg github.com/99designs/gqlgen
//go:generate go run ./scripts/gqlgen.go
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you update the template for resolvers.go?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah interesting. Yeah what should we do there? We can't assume users will have a script to run at scripts/gqlgen.go.

@@ -9,6 +9,9 @@ import (
"github.com/99designs/gqlgen/graphql"
"github.com/99designs/gqlgen/internal/gopath"
"github.com/urfave/cli"

// Required since otherwise dep will prune away these unused packages before codegen has a chance to run
_ "github.com/99designs/gqlgen/handler"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be enough to get init to run cleanly. Attempting to run server/server.go afterwards however still requires some additional deps (websockets I think). So I added a dep ensure after gqlgen init in the docs.

@emil-nasso
Copy link

Is it possible to add an explanation to what ./... means?

This is not unlikely to be the first run in with go generate for many users. The go documentation is not very good or clear on this.

To my understanding it runs go generate in all subdirectories so ./... means "the subdirectories (...) of the current directory (.)".

I think it would help to alleviate some confusion to just have a short explaination like:

You can now run any generation commands for all subdirectories in your project with:

@mathewbyrne
Copy link
Contributor Author

@emil-nasso yeah I think that's a fair comment. I'll add a note.

@@ -88,22 +117,27 @@ type Todo struct {
}
```

And then tell gqlgen to use this new struct by adding this to the gqlgen.yml:
Next tell gqlgen to use this new struct by adding it to `gqlgen.yml`:

```yaml
models:
Todo:
model: github.com/vektah/gqlgen-tutorials/gettingstarted.Todo

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Earlier the doc says:

mkdir -p $GOPATH/src/github.com/[username]/gqlgen-todos

So I think this doesn't match. Probably should be:

model: github.com/[username]/gqlgen-todos.Todo

```bash
rm resolvers.go
gqlgen
$ rm resolvers.go

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me, this is resolver.go no resolvers.go

```

Now we just need to fill in the `not implemented` parts

Now we just need to fill in the `not implemented` parts. Update `graph/graph.go`

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think (for me) this should be "Update resolver.go"

rm ~/go/bin/gqlgen
rm -rf ~/go/src/github.com/99designs/gqlgen
```
At the top of our `resolvers.go` add the following line:
Copy link

@samjbobb samjbobb Nov 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolvers.go -> resolver.go (based on my experience)

@samjbobb
Copy link

Hey thanks for this project and this PR. This updated documentation really helped me get started.

I created a new project and set my Gopkg.toml to:

[[constraint]]
  name = "github.com/99designs/gqlgen"
  branch = "improved-getting-started"

And then ran through the Getting Started guide.

Overall, was successful and the new docs helped. I noticed a couple of discrepancies, so I added some commends to the PR. Hope that's helpful!

Thanks again.

@mathewbyrne
Copy link
Contributor Author

@samjbobb thanks for the input. I think your comments are correct and I'll have a fix in place before this goes out.

Just an update for anyone else wanting this to be merged: since these docs use dep, they will only work once we have a new release out that includes these changes. Once we're ready for a new release (hopefully soon) this will go out.

@mathewbyrne mathewbyrne force-pushed the improved-getting-started branch from ca1c6c5 to b9fbb64 Compare November 28, 2018 02:14
@mathewbyrne mathewbyrne merged commit d6d9885 into master Nov 28, 2018
@vektah vektah deleted the improved-getting-started branch November 28, 2018 03:20
cgxxv pushed a commit to cgxxv/gqlgen that referenced this pull request Mar 25, 2022
Improve Getting Started Documentation — No Binary Approach
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants