Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Jul 21 12:03

    StevenACoffman on v2.4.7

    (compare)

  • Jul 20 18:01
    StevenACoffman commented #229
  • Jul 20 17:55
    StevenACoffman commented #230
  • Jul 20 17:55
    StevenACoffman closed #229
  • Jul 20 17:55

    StevenACoffman on master

    Fix #229 (#230) * account for … (compare)

  • Jul 20 17:55
    StevenACoffman closed #230
  • Jul 20 17:29
    schafle commented #229
  • Jul 13 23:36
    StevenACoffman commented #231
  • Jul 12 23:52
    Aven30 opened #231
  • Jul 12 18:30
    Aven30 edited #230
  • Jul 12 18:20
    coveralls commented #230
  • Jul 12 18:19
    Aven30 synchronize #230
  • Jul 12 18:18
    coveralls commented #230
  • Jul 12 18:17
    Aven30 edited #230
  • Jul 12 18:17
    Aven30 opened #230
  • Jul 07 11:57
    StevenACoffman commented #229
  • Jul 07 04:50
    schafle edited #229
  • Jul 06 23:49
    schafle edited #229
  • Jul 06 23:48
    schafle opened #229
  • Jul 03 21:13

    StevenACoffman on v2.4.6

    (compare)

Adam Scarr
@vektah
:sweat: this rule is gnarly
Masahiro Wakame
@vvakame
agreed.
Adam Scarr
@vektah
:joy_cat:
Adam Scarr
@vektah
@vvakame what are you trying to achieve with that play link?
Unsafe pointer shouldn't be needed?
Masahiro Wakame
@vvakame
I'd tried below patter.
// use i here instead of `i, sel` otherwise you take a pointer to a copy.
for i := range field.SelectionSet {
    w.walkSelection(def, &field.SelectionSet[i])
}

func (w *Walker) walkSelection(parentDef *ast.Definition, it *ast.Selection) {
    // ...
}
Adam Scarr
@vektah
as you said, Selection is an interface
so all they are already pointers
or is the problem that the thing in the interface isnt a pointer?
Masahiro Wakame
@vvakame
type Selection interface {
    isSelection()
}

func (Field) isSelection()          {}
func (FragmentSpread) isSelection() {}
func (InlineFragment) isSelection() {}
problems is here. Selection implemented by Field, FragmentSpread, InlineFragment. not Field, not FragmentSpread, *InlineFragment.
wow, italic..
Adam Scarr
@vektah
feel free to make them func(*Field)?
it will need a few changes to the parser, but that shouldn't be too bad?
Masahiro Wakame
@vvakame
maybe yes.
Masahiro Wakame
@vvakame
my objective is implement OverlappingFieldsCanBeMerged.
Adam Scarr
@vektah
yeah, whats the problem you're running into?
Masahiro Wakame
@vvakame
wait a moment, I'll write problmen's description again.
Masahiro Wakame
@vvakame

I need to visit all SelectionSet and it has Definitions (e.g. Field with FieldDefinition)

  • All sub nodes have Definition too
    • InlineFragment's fields...
    • FragmentSpread's fields...
    • deeply nested foobar's fields...

How can the above be achieved?
I tried below code.

    observers := w.Observers
    w.Observers = &Events{}
    w.walk()

    w.Observers = observers
    w.walk()

However, there were a lot of code call by value and the value was still nil.
(and It's a bit inefficient.)

Do I have to use function arguments as pointers?
It is necessary to change to the following code.

    for idx := range w.Document.Operations {
        child := &w.Document.Operations[idx]
        w.validatedFragmentSpreads = make(map[string]bool)
        w.walkOperation(child)
    }

and... Selection seems difficult unless we change the definition.

Writing as usual would do as follows.
This is a confusing bug that values are ghostly eaten.
    for _, child := range w.Document.Operations {
        w.validatedFragmentSpreads = make(map[string]bool)
        w.walkOperation(&child)
    }
Masahiro Wakame
@vvakame
I will return home from now so check here again later!
Adam Scarr
@vektah

right, so because

type QueryDocument struct {
    Operations []OperationDefinition
}

operations is all allocated contiguously in memory (its very efficient to loop over due to cache coherency, but adding elements can be costly)

Operations: [OperationDefinition(Operation: "query", Name: "", ...)][OperationDefinition(Operation: "query", Name: "", ...)][OperationDefinition(Operation: "query", Name: "", ...)]

the problem is a for loop copies it when traversing:

for i, def := range document.Operation {
    // &def is a pointer to a copy
   // &document.Operation[i] is a pointer to the element of the array
}

wheras if

type QueryDocument struct {
    Operations []*OperationDefinition // note pointer
}

you end up with an array of pointers, referencing objects randomly allocated all over the place

op 3: [OperationDefinition(Operation: "query", Name: "", ...)]
[ptr to 1][ptr to 2][ptr to 3]
op 1: [OperationDefinition(Operation: "query", Name: "", ...)]
op 2: [OperationDefinition(Operation: "query", Name: "", ...)]

when you loop over the pointers, go still copies them, but its a copy of a pointer so it doesnt matter so much, the cost you pay is now your reading things from random locations in memory as you loop, which is much slower if you do it a lot (for operation it probably doesnt matter, you expect a few items max

feel free to make []*things wherever you need, we can always wind them back to []things if they are expected to be lager
pretty sure contiguous arrays are also less pressure on the gc, not having to clean up lots of small references. perf without benchmarks is dumb though, so do what makes sense
Masahiro Wakame
@vvakame
okay, I'll try it later.
Masahiro Wakame
@vvakame
I started going forward!
Adam Scarr
@vektah
and I broke all your code?
:D
vektah/gqlparser#39 makes all the collections []*Thing
Masahiro Wakame
@vvakame
yeah I found it and merge it in 1 min :smiley_cat:
Masahiro Wakame
@vvakame
@vektah I have a question.
https://github.com/vektah/gqlparser/blob/master/spec/validation/deviations.yml#L13-L26
Why these tests are marked skip: true ?
Adam Scarr
@vektah
inherited from the upstream library
we should try and get them implemented
Masahiro Wakame
@vvakame
make sense :thinking_face:
Masahiro Wakame
@vvakame
From tomorrow I will return to another job that is stacked. :wink:
Please let me know if you have anything you would like me to help with.
I can not do much as I go to SanFransisco next week.
Adam Scarr
@vektah
oh wow you finished it!
amazing :heart_eyes:
Adam Scarr
@vektah
@vvakame I've sent you an collaborator invite for gqlparser
I'm tracking stuff for "1.0" on https://github.com/vektah/gqlgen/projects/1, if you see something you want to work on feel free
just drag it into "in progress" so someone else doesn't start working on it
I think Mat will start to break down that directive card some more once he gets his head around how it will all hoook in
Masahiro Wakame
@vvakame
wow, thx. I accepted invitation.
Adam Scarr
@vektah
thanks for all the hard work :D
Masahiro Wakame
@vvakame
If you did not make your code at first, I would not be eager to GraphQL. thanks for your hard work too :sparkles:
Tamal Saha
@tamalsaha
Hello, just trying to learn about GraphQL in Go.
Have you looked into using https://github.com/graphql-go/graphql/tree/master/language parser instead of writing your own?
Adam Scarr
@vektah
Yeah, I looked at a bunch
the parser and lexer are actually really easy