Skip to content
go generate based graphql server library
Go JavaScript Other
Branch: master
Clone or download

Latest commit

vektah Merge pull request #1104 from oshalygin/docs/update-query-complexity-…

Update Query Complexity Documentation
Latest commit a1a0261 Mar 18, 2020


Type Name Latest commit message Commit time
Failed to load latest commit information.
.github run CI on PRs Mar 18, 2020
api revert #1079 Mar 12, 2020
bin Update release process to keep tags on master Jun 27, 2019
client Fix websocket connections on test client Sep 25, 2019
cmd remove os.Exits Mar 4, 2020
codegen suppress golint messages Feb 20, 2020
complexity bump to gqlparser v2 Feb 16, 2020
docs Update Query Complexity Documentation Mar 15, 2020
example fix: Add Upload.ContentType test Mar 2, 2020
graphql v0.11.3 postrelease bump Mar 13, 2020
integration bump to gqlparser v2 Feb 16, 2020
internal fix whitespace in comparison Feb 18, 2020
plugin delete unused code Mar 18, 2020
.dockerignore convert existing tests to jest Aug 9, 2018
.editorconfig Use docker in docker for the existing testsuite Aug 8, 2018
.gitignore Federation docs and examples Feb 8, 2020
.golangci.yml Update to latest golangci-lint Feb 3, 2020 Consolidate Introduction documents Mar 4, 2019
LICENSE Update licence Mar 12, 2020 Fix CI badge Mar 4, 2020 Add a PR template Aug 23, 2018
go.mod Rollback go.sum and go.mod as per feedback of @vektah Feb 22, 2020
go.sum Rollback go.sum and go.mod as per feedback of @vektah Feb 22, 2020
main.go Reintroduce main package in root Feb 18, 2019
tools.go bump x/tools for consistent import formatting Jan 15, 2020

gqlgen Continuous Integration Read the Docs

What is gqlgen?

gqlgen is a Go library for building GraphQL servers without any fuss. gqlgen is:

  • Schema first — Define your API using the GraphQL Schema Definition Language.
  • Type safe — You should never see map[string]interface{} here.
  • Codegen — Let us generate the boring bits, so you can build your app quickly.

Feature Comparison

Getting Started

First work your way through the Getting Started tutorial.

If you can't find what your looking for, look at our examples for example usage of gqlgen.

Reporting Issues

If you think you've found a bug, or something isn't behaving the way you think it should, please raise an issue on GitHub.


Read our Contribution Guidelines for information on how you can help out gqlgen.

Frequently asked questions

How do I prevent fetching child objects that might not be used?

When you have nested or recursive schema like this:

type User {
  id: ID!
  name: String!
  friends: [User!]!

You need to tell gqlgen that we should only fetch friends if the user requested it. There are two ways to do this.

Custom Models

Write a custom model that omits the Friends model:

type User struct {
  ID int
  Name string

And reference the model in gqlgen.yml:

# gqlgen.yml
    model: # go import path to the User struct above

Explicit Resolvers

If you want to Keep using the generated model: mark the field as requiring a resolver explicitly in gqlgen.yml:

# gqlgen.yml
        resolver: true # force a resolver to be generated

After doing either of the above and running generate we will need to provide a resolver for friends:

func (r *userResolver) Friends(ctx context.Context, obj *User) ([]*User, error) {
  // select * from user where friendid = obj.ID
  return friends,  nil

IDs are strings but I like ints, why cant I have ints?

You can by remapping it in config:

  ID: # The GraphQL type ID is backed by
      - # An go integer
      - # or a go string

This means gqlgen will be able to automatically bind to strings or ints for models you have written yourself, but the first model in this list is used as the default type and it will always be used when:

  • Generating models based on schema
  • As arguments in resolvers

There isnt any way around this, gqlgen has no way to know what you want in a given context.

Other Resources

You can’t perform that action at this time.