Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
  • 16:32
    dcarbone edited #2321
  • 16:15
    dcarbone edited #2321
  • 16:15
    dcarbone edited #2321
  • 16:11
    dcarbone edited #2321
  • 16:10
    dcarbone opened #2321
  • Aug 10 10:19
    acmeuniverse commented #2290
  • Aug 09 16:59
    StevenACoffman commented #2317
  • Aug 09 16:58
    StevenACoffman closed #2317
  • Aug 09 12:03
    kockok commented #1044
  • Aug 09 11:09
    frederikhors commented #2319
  • Aug 09 11:09
    frederikhors reopened #2319
  • Aug 09 11:08
    tamas-zolcsak commented #2319
  • Aug 09 10:47
    frederikhors labeled #2319
  • Aug 09 10:46
    frederikhors closed #2319
  • Aug 09 10:46
    frederikhors commented #2319
  • Aug 09 10:45
    tamas-zolcsak opened #2319
  • Aug 09 08:46
    frederikhors closed #2316
  • Aug 09 08:46
    frederikhors commented #2316
  • Aug 09 06:54
    neptoess ready_for_review #2317
  • Aug 09 06:51
    coveralls commented #2317
Davae Wanliss
keep getting weird errors in sub fields that are manged by a federated schema
invalid character '$' looking for beginning of value
it seems to be an unmarshall error
Luke Cawood
hey everyone, we're moving gqlgen chat to discord, here's an invite link :) https://discord.gg/DYEq3EMs4U
Davae Wanliss
Is there any way to control the sequence of resolvers´╝îbecause some resolver depenency other resolver result
Is there a way to set the OperationName from the OperationContext for logging purposes? I know we can intercept the request body and get the value from the context?
Hi, is there a defined order in which resolvers are called, or another way to get access in the resolution process to which fields are being requested
Basically, I want to fire off as few sql queries as possible so I'd like to custom tailor my sql query based on what's being requested
It looks like a clue to my answer is here: https://gqlgen.com/reference/field-collection/
David Pennington

When dealing with client requests for other resolvers, it's normal for the graphql implementations to call whatever nested resolvers were asked for without you needing to do it manually. It seems like with gqlgen, you have to embed a lot of 'if' statements to manually call other resolvers. Imagine a 'well-connected' entity like a user account which might have 10 different checks to https://gqlgen.com/reference/field-collection/ to know what nested resolvers to call. Is this correct?

If I have a query like query { A { B { C { name } } } } do I have to embed if checks in A for B, and checks in B for C?

2 replies
HI there, is there a way or known practices to forward a gql query to another endpoint with gqlgen ?
David Pennington
How do I regenerate the code? go run github.com/99designs/gqlgen and go generate ./... don't seem to pickup changes
Jon Watte
I create a minimal schema (just a type and a query that returns that type) and run "go generate" on 0.17.2, and I get a bunch of errors that all say generated.go:784:15: ec._fieldMiddleware undefined (type *executionContext has no field or method _fieldMiddleware)
Is this known? Something else I need to do first?
Terry Liu

Is there a good resource for how to write a basic filter query while using gqlgen?

For example, if I wanted to filter all members by those with a given name, my schema might look like:

type Query {
  members(name: String): [Member!]! 

How would one cleanly handle this in the resolver? It feels like we would have to check for the name input and then conditionally adjust the underlying SQL query based on the existence of that field by appending a WHERE name = ? clause. That feels so clunky, I'm quite convinced I'm missing something and that there's a better way....

Rick F
Does gqlgen support mapping Enums to alternate, explicit values? Typescript qgl supports creating Enums that map to other strings, for example
enum Direction {
  UP = "up",
  DOWN = "down",
  LEFT = "left",
  RIGHT = "right",
Jon Watte
@sudotliu That is exactly how you need to implement filtering. GQL is not a database query language by itself, and the gqlgen code can't know which particular database or schema you're using, so it can't generate SQL for you. (You might not even be using SQL!)
If you want something that's a little more automatic in that mapping, try something like Hasura. (Not Go, though.)
Nguionza Desire
collected field
Nguionza Desire
Hi! Everyone is there a simple way to get preloaded field in map[string]interface{} format to easily use pluck or projection in nosql database ? My first attempt was to use regex to filter the GetPreloads(ctx) method with something like var regExp = regexp.MustCompile(([\w]+\.)+[\w]+([\s]|$)) then with a loop trying to match nested key and it value but it seem overload for me...instead can we move it the GePreloads(ctx) itself and try to have a work around? for example in rethinkdb pluck need {key: true, nested: {child: true}} to perform...can you guy point me a direction please!!!
Shivam Mishra

I create a minimal schema (just a type and a query that returns that type) and run "go generate" on 0.17.2, and I get a bunch of errors that all say generated.go:784:15: ec._fieldMiddleware undefined (type *executionContext has no field or method _fieldMiddleware)

Hi team

I am also getting same type of error while generating.

Terry Liu

I think I may be misunderstanding something about how autobind works or have simply misconfigured something.

My impression is that setting it like this:

        resolver: true

Means that gqlgen should look to the configured package for custom types already defined to resolve most fields for that type but then also that any explicit fields listed here with resolver: true will have a resolver generate for it regardless.

In my situation, I'm pointing gqlgen autobind package to sqlc-generated models but then resolvers are automatically being generated for far too many fields even when set to resolver: falsein the config for said field.

Any ideas on what I'm missing?

1 reply
Vayuj Rajan
@vyj7 what is your desired result with that loop? to me it looks like your for loop is going to block because of the ctx.Done, which you're describing in your problem.
Seems to me you need to put that block after ctx.Done into a goroutine and have it block until ctx.Done returns, so that you can read each message. Right now, that ctx.Done() is going to block and you'll only send one message over your channel.
Is there any support for stream directive in ggqlgen library ?
Terry Liu

Is it possible to have multiple models be used as the defaults for resolver arguments? For example, if I have two DB models that are effectively backing a single GQL type, is there a way to take the union of fields under the two DB types and have resolvers auto-resolve those?

The only way now seems to be to pick one type to auto-resolve for and then explicitly resolve the reset even if they're still basic scalars that could effectively be pass-through resolution.

I guess one issue with supporting multiple types is that it can get ambiguous when two types share a common field name, but it's easy enough to force those to be custom-resolved.

Hey all, I'm putting together a backend with gqlgen, gin, and gorm. Are there any good tutorials which show you how to configure an authentication flow between the client and server? Thanks
Mihir Mehta
Hi Everyone
I am trying to enable Apollo tracing in gqlgen project but i am not able to find any proper documentation for the same
any idea ?
Jack Wu
How can I avoid // DurationTxt is the resolver for the durationTxt field.
func (r babySleepResolver) DurationTxt(ctx context.Context, obj models.BabySleep) (string, error) {
return "duration", nil
Why I need to resolve the attribute of my model ?
Allan Glen
If I have a model object and I want to serialize it to JSON, is there an easy way to hook into the gqlgen marshaler such that I can produce the same JSON structure that is returned via the GraphQL API (including custom marshalers?)