Skip to content

Modification proposal for the invoke() prototype #22

@vejja

Description

@vejja

Feature request

Is your feature request related to a problem? Please describe.

This feature request is to propose a breaking change to the prototype of invoke() that would:

  • reduce boilerplate for newer folks
  • be opinionated by default but still provide full-powered low-level access on option
  • be syntactically consistent with the from, rpc, storage, and auth APIs

Describe the solution you'd like

The invoke() prototype would look like:

const { data: any, error: FunctionsError } = await invoke(functionName: string, input: any, options?: {requestTransform, responseTransform})

Describe alternatives you've considered

The alternatives are described in greater detail in the conversation of PR #21, but in summary:

  1. The first option would be to move the behavior of invoke closer to that of fetch, but the issue would then be to increase the amount of boilerplate necessary to use the function.
  2. The second option would be to move the behavior of invoke closer to that of Firebase's httpsCallable, but the issue would then be to limit the type of data that can be sent and received to only JSON objects (therefore excluding Files and Blobs for instance).

This proposal is a tentative for a best of both worlds approach, where common data types can be automatically serialized and de-serialized by invoke and therefore reduces the boilerplate for the most common use cases, while also allowing to have full low-level access to the underlying Fetch API if required, via the options parameter callbacks.

Additional context

An implementation proposal is linked to this feature as PR #23
A detailed explanation of the new behavior of invoke is provided in the README.md file of the PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions