-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: Restructure aggregate query syntax #373
refactor: Restructure aggregate query syntax #373
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #373 +/- ##
===========================================
+ Coverage 65.11% 65.26% +0.14%
===========================================
Files 80 80
Lines 9240 9251 +11
===========================================
+ Hits 6017 6038 +21
+ Misses 2607 2595 -12
- Partials 616 618 +2
|
This comment was marked as spam.
This comment was marked as spam.
8489d17
to
47ad426
Compare
This comment was marked as spam.
This comment was marked as spam.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great stuff!
query/graphql/schema/generate.go
Outdated
for _, t := range g.typeDefs { | ||
sumArg := g.genSumBaseArgInputs(t) | ||
sumBaseArgs[sumArg.Name()] = sumArg | ||
// This needs to happen for all types before calling genSumFieldConfig |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By 'this' do you mean the previous chunk of code or the code that follows up until g.genSumFieldConfig(t, sumBaseArgs)
?
Perhaps a line break before (if referring the code that follows) the comment line.
OR a line break after (if referring to the previous chunk of code above) the comment line.
To help make it more obvious?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm thought it was common understanding that comments always apply to the code below them, but I will make it clearer
- Make comment clearer
47ad426
to
fd19c0e
Compare
Benchmark ResultsSummary
✅ See Better Results...
❌ See Worse Results...
✨ See Unchanged Results...
🐋 See Full Results...
|
Benchmark ResultsSummary
✅ See Better Results...
❌ See Worse Results...
✨ See Unchanged Results...
🐋 See Full Results...
|
4878f65
to
c818ee1
Compare
Benchmark ResultsSummary
✅ See Better Results...
❌ See Worse Results...
✨ See Unchanged Results...
🐋 See Full Results...
|
the type names on the Aggregate types are a concatenation of type, field, "AggregateInputObj", which as you can see in the image results in something like But the rest of the types follow a normal camel case, here we have "user" and "points" both lowercase, should prob be "userPointsSumInputArg". Minor but it bugged me :p |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing major, just a few notes.
In general, im not the biggest fan of the field
symbol used for the input args to the sum stuff, but its mostly a function of how the gql spec works, so not much we can do about it atm.
Fields: gql.InputObjectConfigFieldMap{ | ||
"_": &gql.InputObjectFieldConfig{ | ||
Type: gql.Int, | ||
Description: "Placeholder - empty object not permitted, but will have fields shortly", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a todo placeholder that should be resolved in this PR, or by "shortly" are you referring to later?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could have it so theres no input arguments to _count
until theres an actual need to define something here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first will likely be filter, but I'd also want limit and offset available here too at least. _count
still needs input, otherwise there is no way to tell which child you want to count :)
return nil, nil | ||
} | ||
|
||
fieldsEnum := gql.NewEnum(fieldsEnumCfg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't there already a defined type to handle fieldsEnum?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh, there is, but it includes other fields like _key
, _group
, etc. Youre just constructing a "simple" type fields enum. Can prob do it outside of this func, in its own generator, and call it when we make the original type fields enum, so if they need to be reused its more readily available
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah is specific to here (or at least aggregate). Would like to organise these better and maybe rename them when we get round to refactoring generator, or maybe even when implementing average (which should share types with sum I think)
Really good spot - will have a look at that now (even if they get renamed when looking at average) as if it leaks into the release it looks really sloppy |
In preparation for top-level queries, and aggregate filters
Should be a fair bit safer now and easier to read
c818ee1
to
3ad3810
Compare
Sorted, will merge after the build |
Benchmark ResultsSummary
✅ See Better Results...
❌ See Worse Results...
✨ See Unchanged Results...
🐋 See Full Results...
|
* Restructure aggregate query syntax In preparation for top-level queries, and aggregate filters * Rework parser.GetAggregateSource Should be a fair bit safer now and easier to read
Closes #365
Restructures aggregate query syntax in preparation for top-level queries, and aggregate filters as discussed on discord.