Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • 12:56
    sdalezman opened #950
  • Dec 04 17:21
    mmacheerpuppy commented #73
  • Dec 04 17:20
    mmacheerpuppy commented #73
  • Dec 04 11:18
    maddoger commented #866
  • Dec 04 11:18
    maddoger commented #866
  • Dec 04 11:17
    maddoger commented #866
  • Dec 04 11:07
    asiman161 commented #866
  • Dec 04 10:43
    maddoger commented #866
  • Dec 04 10:43
    stale[bot] unlabeled #866
  • Dec 04 10:43
    maddoger commented #866
  • Dec 04 02:50
    josemarluedke commented #851
  • Dec 03 19:10
    tgrander opened #949
  • Dec 03 16:28
    stale[bot] labeled #887
  • Dec 03 16:28
    stale[bot] commented #887
  • Dec 03 07:28
    stale[bot] closed #878
  • Dec 02 06:16
    jensneuse commented #462
  • Dec 01 23:58
    stale[bot] labeled #845
  • Dec 01 23:58
    stale[bot] commented #845
  • Dec 01 17:36
    ravilution closed #928
  • Dec 01 17:36
    ravilution commented #928
Matias Anaya
@matiasanaya
but to fix it I'd need some clarity on what the spec is
Adam Scarr
@vektah
its likely embedded interfaces were never though of :)
Matias Anaya
@matiasanaya
I mean, the binding priority spec. The docs mention that "If a struct_tags config exists, then struct tag binding has the highest priority over all other types of binding" but the code does something different
Adam Scarr
@vektah
it should follow go's order
so real field/method, then embedded
Matias Anaya
@matiasanaya
Ok I'll give this a stab
Matias Anaya
@matiasanaya
@vektah about struct_tag vs method / field: Does it depend on the depth of embedding? What if they are at the same depth? My preference would be to bind to any field or method that matches (irrespective of the embedding depth) then a struct_tag at depth 0 followed by struct tag down the embeds chain. This is the simplest since we can tap into Go's builtin promotion mechanism for embeds, but limits the struct_tag ability to override that.
Matias Anaya
@matiasanaya
Actually I'd try to avoid walking down the embeds chain. Just flatten out the struct tags on all promoted fields and if there are duplicates, fail.
Adam Scarr
@vektah
I think conceptually struct tag matching is replacing the name
they have the highest priority within that "level"
I dont think duplicates are a bug, its quite normal to wrap an object by embedding it and provide a new implementation for one of its fields/methods
Adam Scarr
@vektah
since we can tap into Go's builtin promotion mechanism for embeds,
I'm not sure what you mean here? We still need to determine what is being bound to (method vs field, and type)
Matias Anaya
@matiasanaya
type Truck struct {
    *Part
    *Car
}

type Car struct {
    ID string
}

type Part struct {
    ID string
}
By Go's promotions rules neither of these fields get promoted.
Matias Anaya
@matiasanaya
We can tap into this with types.LookupFieldOrMethod
the current algo would bind to the first embed
Adam Scarr
@vektah
I see
but that would break the struct tag binding
Adam Scarr
@vektah
I wonder how much code is in types.LookupFieldOrMethod?
Could we copy it out?
Matias Anaya
@matiasanaya
How about an initial pass with .NumFields looking for struct_tag and if that fails, we fallback to types.LookupFieldOrMethod? I reckon that could work.
Adam Scarr
@vektah
do you mean recursively or?
Matias Anaya
@matiasanaya
I believe https://golang.org/pkg/go/types/#LookupFieldOrMethod matches all promoted methods and fields. So is my understanding of https://golang.org/pkg/go/types/#Struct.NumFields .
Recursion wouldn't be necessary
Adam Scarr
@vektah
I dont think that's true:
  • go field and method searching is case sensitive, gqlgen needs to handle inexact matches
  • it also needs to handle matching on tags, and finding the matching field. how does NumFields help with that?
Matias Anaya
@matiasanaya
hmmm, didn't know about the case insensitivity requirement.
Matias Anaya
@matiasanaya
and NumFields doesn't return promoted fields, just the actual embeds as you point out, so back to the drawing board.
Matias Anaya
@matiasanaya
@vektah I've pushed an initial fix. It matches my understanding of the spec, but it differs from the previous implementation. The main differences are:
  • Struct tags override both fields and methods
  • All fields and methods at a depth are considered (and can result in an error if more than one match is found) before moving to the next depth
  • Lookes at every embedded field at a depth before it moves deeper (BFS)
  • Handles interfaces (but not at the root level)
Would love some feedback!
sateeshpnv
@sateeshpnv
vscode gets very slow after generating. Is there a known configuration that causes this?
Adam Scarr
@vektah

99designs/gqlgen#885 Is just about done I think.

Would love to get some people to test it out with go get github.com/99designs/gqlgen@handler-refactor

Theres a backwards compat layer in place that should cover nearly everything, the only exception is RequestMiddleware which has a slightly different signature now (the Response object rather than []byte). There should be deprecation messages in place to point you to the new interfaces.

Still need to update the docs

Michael Muré
@MichaelMure
this PR description is quite impressive, you even have diagrams !
Adam Scarr
@vektah
There's a lot going on in that pr, I'll need reminding what soon
Masahiro Wakame
@vvakame
I wrote some comment to PR :cat2:
Adam Scarr
@vektah

Thanks @vvakame, I think I've addressed your comments. Would love a second look, especially around https://github.com/99designs/gqlgen/pull/885/commits/67fa21049567aff73f5ae019683a14b7b03a496d

It makes the assumption that your logger is running as a Response middleware and allows it to easily fetch out the complexity stats. Can be easily extended if we wanted to expose APQ data etc.

Masahiro Wakame
@vvakame
:+1: i tried new one and add some comments!
pradeepkusingh
@pradeepkusingh
How to implement selectionSet, I am newbie , if you have any sample please let me know.
Jon Lundy
@JonLundy
i am not sure i understand the question?
David Douglas
@ddouglas

Hello All. I am in desperate need of some way to log the raw query and variable separately before they are parsed but in a manner that doesn't have them take up multiple lines in the logs.

Example: I need to convert this:

    query($id: Int!) {
        alliance(id: $id) {
            id
            name
        }
        characters: characterCorporationHistoryByAllianceID(allianceID: $id) {
            id
            record_id
            start_date
            corporation_id
            corporation {
                id
                name
                ticker
            }
            character {
                id
                name
                birthday
                gender
            }
        }
    }

to this:

query($id: Int!) { alliance(id: $id) { id name } characters: characterCorporationHistoryByAllianceID(allianceID: $id) { id record_id start_date corporation_id corporation { id name ticker } character { id name birthday gender } } }

Or something there about's.

Any ideas? I have delved very deep into https://github.com/vektah/gqlparser, but I was unable to confidently find what I need.
David Douglas
@ddouglas
Turns out if you don't google something correctly, you're not gonna get the answer you are looking for, however if you google something close to what you want, you find exactly what you are looking for
Adam Scarr
@vektah
Two bits of exciting news today. gqlgen 1.10.2 is out with a bunch of fixes and new features. See the release notes https://github.com/99designs/gqlgen/releases/tag/v0.10.2
And a large refactor of the handler package has landed on master, see https://gqlgen.com/recipes/migration-0.11/. This is the start of 0.11 (not yet released), which will hopefully include a few other big features that might have some bigger BC breaks (federation, better plugin support) before we go to 1.0
Michael Muré
@MichaelMure
congrats, awesome work :)
Leonardo Andrade
@landrade
Good work \o/
Any plans to launch a release candidate for 0.11? It can be useful to get feedback and start testing this new release.
sateeshpnv
@sateeshpnv
@vektah Is there a way to break generated.go into multiple files now?