-
Notifications
You must be signed in to change notification settings - Fork 12
Auto populate pagination params on variables #538
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
base: main
Are you sure you want to change the base?
Conversation
clientGQL.go
Outdated
variables = client.InitialPageVariablesPointer() | ||
} | ||
|
||
if (*variables)["after"] == nil { |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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