Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
  • 16:25
    kevinschaffter edited #2179
  • 16:23
    coveralls commented #2174
  • 16:23
    kevinschaffter edited #2179
  • 16:22
    kevinschaffter edited #2179
  • 16:22
    kevinschaffter opened #2179
  • 16:20
    StevenACoffman closed #2176
  • May 20 23:49
    boojongmin opened #2177
  • May 20 20:51
    coveralls commented #2176
  • May 20 20:42
    dependabot[bot] labeled #2176
  • May 20 20:42
    dependabot[bot] labeled #2176
  • May 20 20:42
    dependabot[bot] opened #2176
  • May 20 19:27
    ianling commented #2174
  • May 20 19:26
    ianling commented #2174
  • May 20 19:25
    ianling commented #2174
  • May 20 19:25
    ianling commented #2174
  • May 20 19:25
    ianling synchronize #2174
  • May 20 18:41
    fredbi closed #1392
  • May 20 18:41
    fredbi commented #1392
  • May 20 13:57
    coveralls commented #2175
  • May 20 13:43
    StevenACoffman commented #2174
its gotta be something like this ?
package graph

//go:generate go run github.com/99designs/gqlgen

import (

// This file will not be regenerated automatically.
// It serves as dependency injection for your app, add any dependencies you require here.

var sess = session.Must(session.NewSession())
var svc = dynamodb.New(sess)

type Resolver struct {
    svc *dynamodb.DynamoDB
okay I see how it happens now
Alexey Yurchenko
Hi. Why I cannot add fields with Query type? type Query { api: Query! } or type Mutation { doSome: Query! }. It produces an error but works in graphql-js
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x7ae2df]

goroutine 1 [running]:
Bogdan St─ânescu

Hi all. Is there a way to get the client's IP address for subscriptions?

It's fairly easy for queries/mutations via HTTP transport (by using a middleware similar to the authentication mechanism).
I'm not sure I can access the websocket client's IP address, and InitPayload does not contain such information

I define a union type, gqlgen help me generate its interface, but not for implementation of the union type's member type, where am I wrong
it generated a model implementation for the union, that is a interface in golang, but I need the union memeber type has the method defined by the interface
Joana Roque
hello! just wanted to ask if the project is still being maintained and what are the steps one can do to contribute :) the readme just points to this gitter room. I read in an issue that someone requested access to github discussions but there's no link anywhere
Bruno Martinez
I found an issue with the default recovery (func DefaultRecover) in combination with the default ErrorPresenter(DefaultErrorPresenter).
This cause a second panic while recovering from the first one due to a cast error.
I could propose a fix, what are the step to be allowed to contribute or to make a PR ?
Jonatan Magnusson
Hi! I have implemented some subscriptions, and today found a problem: I have subscriptions for bookings and each booking have a nested User. If I request the booking including the user with a normal query, everything works as expected. But if I use the same subfields for a subscription, user is always null.
Is this expected behavior?
I have a custom resolver for Booking.user, which does not seem to be called for subscriptions, but works as expected for queries and mutations.
Nhan Thai
Hi, seems like if I add the directive @goField(forceResolver: true) to a field, gqlgen generates both the resolver and the field inside Go struct. What do I do if I only want the resolver?
For example:
extend type Admin {
    user: User! @goField(forceResolver: true)
then I got both
func (r *adminResolver) User(ctx context.Context, obj *model.Admin) (*model.User, error) {
    panic(fmt.Errorf("not implemented"))
type Admin struct {
    User      *User     `json:"user"` <-- I don't want this
Harry Walter
Is there a hook I can use to intercept between when directives and resolvers run?:
2021/02/28 16:20:14 InterceptOperation
2021/02/28 16:20:14 InterceptResponse
2021/02/28 16:20:14 InterceptField
2021/02/28 16:20:14 Directive: todos
--- Here
2021/02/28 16:20:14 Resolver: Todos
2 replies
I need the directive to add some default value that can then be read in my hook in order to prevent the resolver running or not
Harry Walter
Or is it perhaps possible to hook into the codegen to apply a default directive?
Li Guangsheng
I'm looking for the ability to add any custom struct tags right in gql type defenition. How about 99designs/gqlgen#1173 ?
Mahendra Kumar
Hello, I'm looking for way to add constraint validation directive, but i dont see any example, can anyone help with a link?
Gabriel Balint
Hello, do you guys have any resources for using gqlgen with aws appsync?
Iko Uchiha
Hi everyone

I had a question. Is it possible to have multiple query resolvers?

as in normally, there is one /query route and then one can do say
query {
companies { name }

but I need something like.

because I need to manage access for different user type

Iko Uchiha
in gqlgen yaml file, is there a way to have multiple resolver directory ?
Iko Uchiha
I wanted to split my schema.resolvers.go into multiple packages. across directories. right now in the yaml file, there is a config called resolver: and then it has dir:, and some follow-schema. is it possible to split this into multiple packages. otherwise when there are quite a few domains it becomes cluttery. I could split it across files, but ideally I want like people/schema.resolvers.go and companies/schema.resolvers.go for separation of concerns
Iko Uchiha
is the question wrong?
Christopher Britz
wondering if there is a way in a schema directive function to know when last resolver/value is being run. I do validation for input types using directives ie minLength=1 and want to return an array of gqlerrors instead of one at a time
het jagani
Hi guys, I am having really bad with some problem when I try to decode object in a middleware. I want to access the query string of a object in middleware but I am not able to do so.. You can find the details here 99designs/gqlgen#1527. Can anyone take a look at it. Thanks in advance for any help.
Wisdom Ogwu
Seems people don't get replied often here.
I just defined some unions in my schema file, after running generate, my generated model contained some interfaces.
But my resolvers didn't change e.g. created a union FileResult = File or Error but my resolver still returns type File
How do I make use of unions?
Wisdom Ogwu
Stupid me, I literally didn't change the return value in my schema to fit the union.
Andrew Marine

Hi all. I have been using gqlgen for a while. I am attempting to add to a fairly large project which has been working for a while but now I am running into this error which I have not seen before. This occurs when I try to generate

generating core failed: generated!.gotpl: template: generated!.gotpl:53:38: executing "generated!.gotpl" at <$field.ComplexitySignature>: error calling ComplexitySignature: too many collisions, last attempt was graphql10

It doesnt give me too much to go off of. Where do I start to dig into the root cause of this?

1 reply
Andrew Marine
Our GraphQL server has a number of models where we want to bind to a method on the model instead of generating a resolver on the root resolver. like this. What is the best way to access the database from in the model? Is it possible to have the dependancies injected into the resolver also injected into the model?
Jonathan Duck
Your model method can have a first argument of context.Context. We've used that to pass all sorts of values throughout our app. (DB connection, Session, Logger, etc.). An http/operation middleware can inject the values in the context for all requests.
1 reply
Anthony Lobko
Hi, new here, just wondering how to use the apollotracing handler that's listed https://github.com/99designs/gqlgen/tree/master/graphql/handler/apollotracing . I don't see it documented anywhere how to set it up, but I really wanted to see this kind of telemetry if it's supported
Anthony Lobko
Nevermind, sorted it out
Andrew Ray
I'm trying to figure out how to build the gqlgen project locally. I ran go generate ./... and spat out 4 package lines, then hung for 10 minutes, so I killed it
when I run it again, it spat out some error lines, and now it's hanging again