colymba / silverstripe-restfulapi

SilverStripe RESTful API with a default JSON serializer.
BSD 3-Clause "New" or "Revised" License
64 stars 34 forks source link

Specify fields to be returned #84

Open dylanitorium opened 6 years ago

dylanitorium commented 6 years ago

Hey colymba,

Love your work.

I was wondering if you'd accept a PR that extended the Basic Query Handler and Serialiser that would allow the user to specify which fields they would like to be returned, something like:

?__fields=ID,Title or ?__fields[]=ID&__fields[]=Title or both

Cheers! Dylan

nimeso commented 6 years ago

I +1 this, It would really help.

colymba commented 6 years ago

Hey @dylanitorium, yes very much interested :) Since a lot of this sort fo task (filtering fields) have been done in the serialiser which semantically isn't that great. So... let's do it!

Do you know the impact/convention/constraint or using ?__fields=ID,Title or ?__fields[]=ID&__fields[]=Title? I think I had like to stick with just one, and I feel __fields[] is most natural one, but might make the URL length quite long?