Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
  • 06:07
    abagshaw commented #895
  • 02:20
    tankbusta commented #1424
  • 02:19
    tankbusta commented #1424
  • 00:28
    dncohen edited #1447
  • 00:27
    dncohen opened #1447
  • Jan 25 19:57
    lkatkus closed #1446
  • Jan 25 18:15
    lkatkus opened #1446
  • Jan 25 14:58
    steebchen edited #1445
  • Jan 25 14:58
    steebchen opened #1445
  • Jan 24 01:27
    coveralls commented #1444
  • Jan 24 01:25
    lisowskibraeden edited #1444
  • Jan 24 01:25
    lisowskibraeden opened #1444
  • Jan 22 07:26
    carldunham commented #1118
  • Jan 22 06:43
    carldunham commented #1212
  • Jan 22 01:57
    coveralls commented #1285
  • Jan 22 01:56
    benjaminjkraft synchronize #1285
  • Jan 22 01:47
    coveralls commented #1285
  • Jan 22 01:47
    benjaminjkraft commented #1285
  • Jan 22 01:46
    benjaminjkraft edited #1285
  • Jan 22 01:45
    benjaminjkraft synchronize #1285
Olivier Refalo
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
how do I tell gqlgen to generate resolvers?!
Olivier Refalo
tried with this
        resolver: true # force a resolver to be generated
        resolver: true # force a resolver to be generated
Olivier Refalo
I got it to compile by changing this:

// Product returns generated.ProductResolver implementation.
func (r *Resolver) Product() productResolver { return productResolver{r} }

// User returns generated.UserResolver implementation.
func (r *Resolver) User() userResolver { return userResolver{r} }

type productResolver struct{ *Resolver }
type userResolver struct{ *Resolver }
still the schema Query doesn't show neither Product nor User
actually... the schema doesn't have a Query type.. so I would think it's normal. ok need to sleep
Olivier Refalo
ok - I got it working... at last
Simeon Miteff
Hi There. is graphql.AddError() expected to work in subscription resolvers?
Simeon Miteff
I'm starting a goroutine in my resolver and returning a channel and nil error (unavoidable - I need to return the channel early to get async responses), so no opportunity to pass the error via return. I add the error to the response context in the goroutine, but the resolver never sends an error down the websocket connection - it just sends a stop message.
Hi there... Is there any example to use gRPC transport instead of HTTP?
Simen A. W. Olsen
Hello! I'm trying to build a BFF based on gqlgen and I'm having issues with using models gqlgen.yaml. I want to reference the models generated by protobuf, so that I can easily pass the result from the GRPC client. The examples are reassigning to the generated model manually, my types are larger, so it would be very much boilerplate. However, when I try to set the models in the configuration file, gqlgen command generates resolvers for all nested structs. How do avoid it? I haven't been able to turn them off, is there a trick?
@javiroberts I think there is a filename_template key to set the resolver name in config file config

Hi there.
I have a validate directive directive @validate(rule: String!) on INPUT_FIELD_DEFINITION.

and the directive implemention:

func validateDirective(ctx context.Context, obj interface{}, next graphql.Resolver, rule string) (res interface{}, err error) {
    res, err = next(ctx)
    if verr := validate.Var(res, rule); verr != nil {
        return nil, verr

    return res, nil
what's the best approach to have validation messages in graphql errors. I mean the fields and related errors.
for now I'm returning only one field's error for a request because the directive is executed once for field and the returns. But I want to return error for multiple fields.
Jan Krynauw

Hi, I'm new here...
We currently have a graphQL server running in NodeJS and Apollo Server making use of authentication outside of the GraphQL layer. Rather than doing any authentication or authorization work in the GraphQL layer (in resolvers/models), it’s possible to simply pass through the headers or cookies to your REST endpoint and let it do the work.

// src/server.js
context: ({ req }) => {
 // pass the request information through to the model
 return {
   models: {
     User: generateUserModel({ req }),
// src/models/user.js
export const generateUserModel = ({ req }) => ({
 getAll: () => {
   return fetch('http://myurl.com/users', { headers: req.headers });

Would something like this be possible with gqlgen and resolvers using gRPC (instead of REST)?

hi how can i set type for model.fields?
// Defining mutation function
func mutateHook(b *modelgen.ModelBuild) *modelgen.ModelBuild {
    for _, model := range b.Models {
        for _, field := range model.Fields {
            field.Tag += ` orm_binding:"` + model.Name + `.` + field.Name + `"`
        model.Fields = append(model.Fields, &modelgen.Field{
            Description: "ex",
            Name:        "ex",
            Type:        model.Fields[0].Type,
    return b
hi all, I am getting 422 status code and no data is not found. Throws an error "Error: Objects are not valid as a React child (found: Error: Response not successful: Received status code 422). If you meant to render a collection of children, use an array instead." for a query made from Apollo client. However the query works fine in the graphql editor

How to efficiently implement broadcasting?

I have a Subscription that emits a new value every second. Multiple (100+) clients are subscribed to it using the same exact query.
Does gqlgen cache similar queries? If not, is it possible to have single resolver / executor / marshaler rather than one per subscribed client?

Hello. I would like to build a modular app structure with gqlgen. For examples I will have blog and auth folder
and I would like to put all schema related to blog under blog folder
like schemas, resollvers etc
I couldn't find any example.
Erik Müller
Screenshot 2020-09-17 at 21.44.46.png
Hi all, I keep hitting the "transport not supported" error. Does anyone know what this means/how to solve it?
(I'm doing a POST)
I using Chi for routing:
func NewRouter(r *chi.Mux, h http2.AppHandler, j *jwtauth.JwtAuth) *chi.Mux {
    r.Route("/graphql", func(r chi.Router) {
        r.Handle("/", playground.Handler("GraphQL playground", "/query"))
        r.HandleFunc("/query", h.GraphQL.Handle)
    return r
Erik Müller
Ah, think I found the issue, I was creating my sever using the New func (which does not add any "protocols") instead of the NewDefaultServer func (which adds a bunch of default "protocols")
Kfir Ozer
can anyone provide information about the status of custom struct tags ? (99designs/gqlgen#1173) I want the types that I define will have "db":value with same value of the json hinting in order for sqlx to work with it properly
Kfir Ozer
never mind i implemented it using https://gqlgen.com/recipes/modelgen-hook/
Jonatan Magnusson
Hey! I'm trying to add a simple custom DateTime scalar that uses RFC3339 to serialize to/from string. type DateTime time.Time.
All is fine, except I can't get gqlgen to find the type!
I have this in gqlgen.yaml:
    model: github.com/MyOrg/MyRepo/internal/backend/gql/gqlresolvers.DateTime
Jonatan Magnusson
Oh never mind! Found it: my problem was that the folder containing package "gqlresolvers" was called "resolvers".
Jonatan Magnusson
One thing I'm not quite sure how to handle is how data could/should be passed on to nested resolvers:
Project I'm working on has some model types, that are not the same as the model types generated by gqlgen. They are typically quite similar though, and I use mappers to translate them back and forth.
When a nested, custom resolver (let's say the User model has Cars) is called, the gqlgen generated User model will be passed to the resolver. But what if I need access to the non-generated model?
Jonatan Magnusson
In my case, the models reflect a postgres database table, and I can use the ID in the generated User type to fetch the user from database again in the resolver, but I don't want to fetch the same user more than once in a single query. Should I rely on data loader in that case? Or should I pass the user in context or Resolver type?
Samuel Suter
Hey all! I wonder if someone is available to talk through this issue? 99designs/gqlgen#1256
In short: type System gets used when federation is enabled, meaning, we cannot have a type of the same name in our schema anymore. Thankfully, we're still at the inception stage of our project, so we can still adjust our schema without external impact. Though I'd love to be able to have a System type in my own schema ;-)
Tassios Marios
Hello guys, I have a question regarding the error logging of the handler. Basically when I am sending a POST request to the server without specifying the content type I am receiving this error {"errors":[{"message":"transport not supported"}],"data":null} which is totally fine. What I need is to log that error, can you please give me an idea about that ? Thank a lot !!!
Farhan Syed

Hi there guys. I have a question regarding plugins and custom resolvers, and the best way to use them.
I came up with a really convuluted solution and I think I made a wrong turn.

For some background info.

  • We are using graphql to basically wire up all our micro services
  • All these microservices use protobuff for their service layer which means we have awesome gerneated code for that
  • We would love to reuse those generated models to be our models for graphql
  • So we wrote a tool to take proto files and turn them into a graphql spec.
  • We also are utilizing autobind feature so that we can point graphql models to the protobuff ones

Of course things don't overlap.

Enums in graphql are strings
Enums in protobuff are int32

Cool we should be able to write a custom resolver for this since the code to do this dead simple and we have TON of enums. We would like to reduce how much code humans need to write.

So I tried writing a plugin.
I realized that all i really wanted to do was basically modify this line https://github.com/99designs/gqlgen/blob/master/plugin/resolvergen/resolver.go#L108 ; and just write an implementation for specifc types.

However for me to do this. I had to copy the entire resolvergen plugin and just modify those few lines. I copied this becuase of this issue 99designs/gqlgen#1058.

Is this still the only way to do this? Anything I really got wrong here?
I'd love just to beable to do this in a much smaller footprint.

Chethan C


I am making a call to graphql web endpoint {{url}}/query with the below graphql query from postman

query getWarGames {
  warGames {

but I am getting floowing error

    "errors": [
            "message": "operation  not found"
    "data": null

Any idea what could be the issue?

Jonatan Magnusson
Hey! I've built a middleware that put the session user id in Context. In my resolvers, I can then get that user id from context, fetch the user, and check the users permission based on role and other things.