Skip to content
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

Drive API, Partial resources: "fields" request parameter not settable #104

Open
fmenou opened this issue Apr 11, 2018 · 1 comment
Open

Comments

@fmenou
Copy link

fmenou commented Apr 11, 2018

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 ❤️ .

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=*" }
@hsenag
Copy link

hsenag commented Feb 27, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants