go generate based graphql server library
Alternatives To Gqlgen
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
Graphql Engine30,513316 hours ago17June 22, 20222,178apache-2.0TypeScript
Blazing fast, instant realtime GraphQL APIs on your DB with fine grained access control, also trigger webhooks on database events.
Rxdb19,950828411 hours ago502December 03, 20236apache-2.0TypeScript
A fast, local first, reactive Database for JavaScript Applications
Graphql Js19,76933,25715,32512 days ago238October 14, 2023274mitTypeScript
A reference implementation of GraphQL for JavaScript
Apollo Server13,5445,3261,4154 days ago313November 14, 202364mitTypeScript
🌍  Spec-compliant and production ready JavaScript GraphQL server that lets you develop in a schema-first way. Built for Express, Connect, Hapi, Koa, and more.
Crystal12,2637612219 hours ago233October 30, 202368otherTypeScript
🔮 Graphile's Crystal Monorepo; home to Grafast, PostGraphile, pg-introspection, pg-sql2 and much more!
11 hours ago2June 08, 2018631apache-2.0Python
A graph-relational database with declarative schema, built-in migration system, and a next-generation query language
Graphql Code Generator10,41918913 hours ago1,363November 27, 2023526mitTypeScript
A tool for generating code based on a GraphQL schema and GraphQL operations (query/mutation/subscription), with flexible support for custom plugins.
Gqlgen9,3271158952 days ago219December 03, 2023261mitGo
go generate based graphql server library
Type Graphql7,8762774309 days ago70August 17, 2023117mitTypeScript
Create GraphQL schema and resolvers with TypeScript, using classes and decorators!
Graphql Editor5,90035 days ago107November 30, 202316mitTypeScript
📺 Visual Editor & GraphQL IDE.
Alternatives To Gqlgen
Select To Compare

Alternative Project Comparisons


gqlgen Integration Coverage Status Go Report Card Go Reference Read the Docs

What is gqlgen?

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

  • gqlgen is based on a Schema first approach — You get to Define your API using the GraphQL Schema Definition Language.
  • 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

Quick start

  1. Initialise a new go module

    mkdir example
    cd example
    go mod init example
  2. Add to your project's tools.go

    printf '// +build tools\npackage tools\nimport (_ ""\n _ "")' | gofmt > tools.go
    go mod tidy
  3. Initialise gqlgen config and generate models

    go run init
    go mod tidy
  4. Start the graphql server

    go run server.go

More help to get started:

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.


We welcome contributions, Read our Contribution Guidelines to learn more about contributing to 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 it should only fetch friends if the user requested it. There are two ways to do this;

  • Using Custom Models

Write a custom model that omits the friends field:

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
  • Using Explicit Resolvers

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

# 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

You can also use inline config with directives to achieve the same result

directive @goModel(model: String, models: [String!]) on OBJECT
    | SCALAR
    | ENUM
    | UNION

directive @goField(forceResolver: Boolean, name: String, omittable: Boolean) on INPUT_FIELD_DEFINITION

type User @goModel(model: "") {
    id: ID!         @goField(name: "todoId")
    friends: [User!]!   @goField(forceResolver: true)

Can I change the type of the ID from type String to Type Int?

Yes! You can by remapping it in config as seen below:

  ID: # The GraphQL type ID is backed by
      - # a 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 isn't any way around this, gqlgen has no way to know what you want in a given context.

Why do my interfaces have getters? Can I disable these?

These were added in v0.17.14 to allow accessing common interface fields without casting to a concrete type. However, certain fields, like Relay-style Connections, cannot be implemented with simple getters.

If you'd prefer to not have getters generated in your interfaces, you can add the following in your gqlgen.yml:

# gqlgen.yml
omit_getters: true

Other Resources

Popular Graphql Projects
Popular Schema Projects
Popular Application Programming Interfaces Categories
Related Searches

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.