-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Fix duplicate fields in preloads #1161
Conversation
Thoughts @RichardLindhout ? |
There are cases where this is needed I think with fragments, maybe we need to remove duplicates but there was a case when something was inside fragments we need this. I think this issue was posted here. Maybe this is resolved now with newer versions? My issue back then: More on that issue here: Maybe we could do a function where we only append if not exist yet. I did not see this problem before. Do you have a query which result in duplicates? I generate type-safe preloads here: Latest helpers: |
I think if you don't include it, selections won't resolve nested fragment fields. However removing duplicates would be a good idea. |
This returns an array of Chats in a Search Response. I was seeing duplicates, when I fetched the fields, as shown in documentation. Every nested field was duplicated. I am not using any fragments, Maybe there no duplicates when using fragments. However, for simple queries, it causes duplicates, maybe you can remove duplicates (or insert in to the array if it is not present array). |
Don't have time to test a.t.m. Maybe this instead of appending func appendPreloadIfMissing(preloads []string, preloadToAdd string) []string {
for _, preload := range preloads {
if preload == preloadToAdd {
return slice
}
}
return append(preloads, preloadToAdd)
} |
Field are indeed duplicated but for me only column.Selections returned the right fields for me with fragments. SelectionSet did not |
This should fix it: #1189 |
This is a documentation change, where we are looping over Selections Twice, which is causing duplicates. I've removed one nested preload to removed these duplicates.