Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
  • May 06 19:05
    patilakshay227 edited #1531
  • May 06 19:00
    patilakshay227 commented #1531
  • May 06 18:58
    patilakshay227 opened #1531
  • May 06 14:58
    ngrilly opened #1530
  • May 06 10:15
    khanakia commented #800
  • May 06 10:12
    khanakia commented #384
  • May 06 10:11
    khanakia commented #800
  • May 06 09:45
    mathieupost opened #1529
  • May 06 09:28
    mathieupost edited #1528
  • May 06 09:27
    mathieupost opened #1528
  • May 06 06:51
    NateScarlet commented #1369
  • May 05 15:35
    ogrok commented #1191
  • May 05 15:35
    ogrok commented #1191
  • May 05 03:36
    khelif96 commented #813
  • May 03 17:20
    kevinmbeaulieu commented #1309
  • May 03 08:02
    TuringJest commented #463
  • May 03 08:01
    TuringJest commented #463
  • May 01 19:40
    HectorMalot commented #1334
  • Apr 30 17:11
    hetjagani opened #1527
  • Apr 30 07:33
    simborg opened #1526
Kishyr Ramdial
Hi everyone. I'm having a bit of a weird issue that I'm trying to narrow down. Every so often (can be within days, hours or within 30 minutes) I start getting 'too many open files' log messages in syslog. When I run lsof, I see hundreds of sock connections to my gqlgen-based server. I've already changed the open-files limit on my OS. I have 3 subscriptions, my app is private and only developers are connecting to it. It "feels" like the websocket part of my server is not closing these connections. Has this happened to any of you, or do you have any tips for me?
Emil Shakirov
Hello everyone!
Is it possible to force gqlgen to throw an error when there is a mismatch between enum values between the resolver response and the schema?
Currently, if the resolver returns enum field with a value that is different from schema definition, it silently renders it into the response without any error.
Is it expected behavior? Should the validation logic for enum be implemented separately?
Anyone got any examples of testing resolvers? ideally unit testing i guess...
Jeremy Marshall
@NickBlow I have this which is my top level tests using ginkgo/gomega. Its a frontend to a Kube controller. It uses a fake/mock kube api


Say I have a custom ID implementation (called GlobalID), but my models all contain a string ID. Can I point gqlgen into a function that converts a string to GlobalID
instead of it generating ID resolvers for every model?

Alik Send

@yuvalt7 better yet https://gqlgen.com/reference/scalars/#custom-scalars-with-third-party-types

    model: path/to/your/file.GlobalID

and in file implement MarshalGlobalID and UnmarshalGlobalID functions

Alik Send

Hi. I created fix for #965 ("Support fields that return top level operations"): #1200
The final implementation contains:

  • generating models without fields for root types (Query, Mutation etc) (plugin/modelgen/models.go)
  • skip generating resolver for field with root type and always return empty struct (codegen/field.go, codegen/field.gotpl)
  • fixes for templates to pass necessary number params to generated methods (codegen/type.gotpl that depends on codegen/config.TypeReference's Root field, that added in codegen/config/binder.go)

Also there are small improvements like adding IsRootDefinition method to Config to not to repeat def == c.Schema.Query || def == c.Schema.Mutation || def == c.Schema.Subscription everywhere

Who can review and merge it?

Build fails because generator on CI for some reason creates oneline methods instead of multiline:

-func (r *Resolver) BackedByInterface() BackedByInterfaceResolver {
-    return &backedByInterfaceResolver{r}
+func (r *Resolver) BackedByInterface() BackedByInterfaceResolver { return &backedByInterfaceResolver{r} }


Alik Send
I can fix it in my PR but then check-fmt will fail
Alik Send

fix for #965

For #956 *

Akhil Indurti

Hey folks, my team’s use-case requires creating and destroying connections/pool at the resolver-level. We want to destroy these connections when a parent and its children are done. Is there any way to know, for a particular parent, when its child resolvers have finished executing?


Kirill Tatchihin
hello everyone! I would like to access field context in dataloader’s fetch function, can I do this?
1 reply

Has anyone got gqlgen run within a bazel project?

It fails with "merging failed: unable to find type github.com/99designs/gqlgen/graphql.Boolean". vendor directory does have these types. I guess I am not able to tell gqlgen (or go) to look for the types in vendor directory.

@vektah ^, please help.
any example Unmarshal & Marshal primitive.ObjectID for MongoDB for model ? I want make scalar ObjectID to primitive.ObjectID

I was put this

      - go.mongodb.org/mongo-driver/bson/primitive.ObjectID

it was created on my model_gen.go
I got error validates like this : validation failed: packages.Load: .../resolver/generated.go ec.unmarshalInputObjectID undefined (type *executionContext has no field or method unmarshalInputObjectID)

I am afraid when into production this will make issue on my app ,
any idea?

trying again like this:
func MarshalObjectID(v primitive.ObjectID) graphql.Marshaler {
    return graphql.WriterFunc(func(w io.Writer) {
        err := json.NewEncoder(w).Encode(v)
        if err != nil {

func UnmarshalObjectID(v primitive.ObjectID) (primitive.ObjectID, error) {
    return v, nil
cannot use v (variable of type interface{}) as primitive.ObjectID value in argument to model.UnmarshalObjectID
4 replies
Swarup Donepudi
Anyone using Galen to run a subscription server?
2 replies

is there any example for Add header in Testing with gqlgen ?

testClient.AddHeader("Token",  TOKEN_HERE)

I wrap them in MustPost() but got token contains an invalid number of segment I bet the header was nil or can't set up

Swarup Donepudi
@vektah do you know if anyone is using gqlgen to run a subscription server.?
Kaarthik Rao Bekal Radhakrishna
Has anyone bound a graphql type that implements an interface to a protobuf message?
Eric Meier
@swarupdonepudi i am
Nur Kutlugallyamov
Hi everyone. Could you look at my PR(#1209) and give me feedback?
Does the package need this (un)marshaler?
What should I add or remove from PR(#1209)?

Can I create type with query: Query! field?

I am trying to generate by

type Login {
  query: Query!
  user: User

and get error

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x18 pc=0x8850c3]

goroutine 1 [running]:
exit status 2
Tassios Marios
Has anyone used dataloaders with field collection ? Because I am trying to do that but I have some issues with the context.
Tassios Marios
@vektah Hi guys, here I have also created an issue regarding the question that I already asked, if somebody faced the same issue or there is a workaround let me know please. Thank you in advance !! 99designs/gqlgen#1225
Ng Thong
who have a example gqlgen vs relay connection ?
i don't know use global ID in gqlgen :(
Swarup Donepudi
Thanks @mariosttass
Is there a way to get the name of each operation as it is being performed using middleware?
Javi Roberts
Hi everyone! Is there a way to define a naming schema for resolver files? Such as resolver/schema.go instead of schema.resolvers.go
Swarup Donepudi
+1 for the ability to override the name for resolvers. Not sure if gqlgen supports it.
Kashif Shaikh
@art1415926535 you can’t embed Query field into another field
Alec Benzer
hey, trying to get started w/ gqlgen (edit: sorry, cat hit enter)

we have a monorepo, and I want to have the gqlgen "root" be a subdirectory of the overall repo. is that possible?

I'm getting an error like module gitlab.com/mycompany/monorepo@latest found, but does not contain package gitlab.com/mycompany/monorepo/go/path/to/gqlgenroot/graph/model

maybe a related clarifying question... in a setup where the gqlgen "root" is not the repo root, a) where should gqlgen.yml go, b) where should the paths in gqlgen.yml be relative to?
Hi guys, i have a question, is a way to get a query fields not from a rezolver, but from a middleware?
Kaarthik Rao Bekal Radhakrishna
oCtx := graphql.GetOperationContext(ctx) start, query, variables := oCtx.Stats.OperationStart, oCtx.RawQuery, oCtx.Variables
Have you tried this?

While migrating from v0.10.2 to v0.11.3, generated.go doesn't compile:

/private/var/tmp/_bazel_sateesh/.../sandbox/darwin-sandbox/1531/execroot/__main__/bazel-out/darwin-fastbuild/bin/src/.../generated.go:4521:20: undefined: gqlparser

generated.go does not import gqlparser github.com/vektah/gqlparser/v2. However, it is used as var parsedSchema = gqlparser.MustLoadSchema(sources...)

How did the gqlparser import vanish from generated.go file?

4 replies
Erik Müller
Hi all, is it possible to generate only the model files? I don't need the server/resolver part as I'm using AWS AppSync. But I have some Lambdas that should use the same models.
Erik Müller
Is there an option to ignore "undefined" directives? I'm using @aws_cognito_user_pools (see AppSync Guide) and I want gqlgen to ignore/skip it as authentication is already handled by AppSync.
Olivier Refalo
Hi.. a bit confused about gqlgen. anyways.. I tried to get the federation-demo working on the latest version with no success.
any idea?
Olivier Refalo
schema.resolvers.go:43:40: ProductResolver not declared by package generated
/schema.resolvers.go:46:37: UserResolver not declared by package generated
pulling my hairs