Drive API, Partial resources: "fields" request parameter not settable
Partial responses
The official documentation of partial resources is misleading:
By default, the server sends back the full representation of a resource after processing requests.
This is blatantly false, at least for Files* endpoints.
The default behavior for the Drive API is to return a subset of fields for at least the GetFile endpoint unless one explicitly ask for more fields.
This is not yet settable in the gogol-drive generated endpoints
The fields request parameter common to all Drive API endpoints can't be set at the moment. This is one of the "Standard Query Parameters".
I can get why it's missing since it's specified globally here.
The fields query param might be a very interesting add to the gogol-drive module :)
Since I'm still discovering the gogol-* modules I won't pretend to know how to do that. I'm just an humble and happy user of it, you guys rock :heart: .
My workaround for information
One option is to set fields to * to have the whole data as a query param.
I've a dirty workaround for my local usecase consisting of patching the Network.HTTP.Client ManagerSettings with managerModifyRequest:
import Data.ByteString (isPrefixOf)
import Data.Semigroup ((<>))
import Network.HTTP.Client (ManagerSettings, Request,
managerModifyRequest, path,
queryString)
managerSettings :: ManagerSettings
managerSettings = tlsManagerSettings { managerModifyRequest = askAllFieldsForFiles }
askAllFieldsForFiles :: Request -> IO Request
askAllFieldsForFiles req
| "/drive/v3/files/" `isPrefixOf` path req = askAllFields req
| otherwise = pure req
askAllFields :: Request -> IO Request
askAllFields req = pure req { queryString = queryString req <> "&fields=*" }
Thanks a lot for this workaround - I just ran into the same problem. It looks like the path is just /drive/v3/files with nothing after now so I had to tweak the guard a bit.