Auto populate pagination params on variables#538
Auto populate pagination params on variables#538andrewstillv15 wants to merge 6 commits intomainfrom
Conversation
clientGQL.go
Outdated
| variables = client.InitialPageVariablesPointer() | ||
| } | ||
|
|
||
| if (*variables)["after"] == nil { |
There was a problem hiding this comment.
There isn't a spread operator in go from what I can tell, very open to other suggestions for this.
There was a problem hiding this comment.
I think the function you have is fine but for the future writing something that merges 2 maps would be more future proof.
func mergeMaps(map1, map2 map[string]any) map[string]any {
merged := make(map[string]any)
for key, value := range map1 {
merged[key] = value
}
for key, value := range map2 {
if _, present := merged[key]; !present {
merged[key] = value
}
}
return merged
}
Then you can just have something like
func (client *Client) PopulatePaginationParams(variables *PayloadVariables) *PayloadVariables {
if variables == nil {
variables = client.InitialPageVariablesPointer()
}
return mergeMaps(variables, client.InitialPageVariablesPointer())
}
b7262e9 to
6f79364
Compare
|
@rocktavious I've hit all the low hanging fruit with respect to the variables == nil behaviour. There are a few (4) more spots with a bit more complexity that I can look into to but before I do, I want to make sure that the testing scope of this isn't much beyond the test cases run in the CI. These changes are non-breaking so it should be safe, but I just want to double check before continuing. |
|
@andrewstillv15 - Good to stop and check. I think most of our tests use "nil" on the I think we potentially have some non-nil ones in some of the sub resource calls on like Service or Teams maybe. The option that is likely WAY simpler to implement is to just put the new common.go functions under test. As long as |
Resolves #
Problem
Round out setting pagination logic such that they are truly optional params.
Solution
Checklist