vektah / dataloaden

go generate based DataLoader
MIT License
530 stars 79 forks source link

Pointer option #24

Closed damour closed 5 years ago

damour commented 5 years ago

For now there is no way to return slice of pointers to value (common case in grpc for repeated fields). Proposed add new -pointer flag that can works with/without -slice option. This is backward incompatible change.

codecov[bot] commented 5 years ago

Codecov Report

Merging #24 into master will not change coverage. The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #24   +/-   ##
=======================================
  Coverage   81.91%   81.91%           
=======================================
  Files           2        2           
  Lines          94       94           
=======================================
  Hits           77       77           
  Misses         16       16           
  Partials        1        1
Impacted Files Coverage Δ
example/user.go 0% <ø> (ø) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update ce6bd88...3b57df7. Read the comment docs.

vektah commented 5 years ago

Can we preserve BC by defaulting is pointer to is slice?

vektah commented 5 years ago

If we need a bc break it might be time to parse a type string a little better, eg -type []*foo.User

damour commented 5 years ago

Can we preserve BC by defaulting is pointer to is slice?

Yes. To preserve BC we need something like this: 1) if slice=false default pointer=true 2) if slice=true default pointer=false

IMHO this approach is not looks consistent and intuitive for users.

If we need a bc break it might be time to parse a type string a little better, eg -type []*foo.User

Good suggestion! I'll remove slice flag from https://github.com/vektah/dataloaden/blob/master/dataloaden.go#L13 and add type parsing.

damour commented 5 years ago

@vektah done, PTAL.

frederikhors commented 5 years ago

I need this too.

I would love to help in development but as I am still learning Go I don't know how. You are doing a great job.

vektah commented 5 years ago

Closing in favor of https://github.com/vektah/dataloaden/pull/28