Skip to content

Conversation

lisajian
Copy link

@lisajian lisajian commented Aug 28, 2025

Description

Adds basic FDC function trigger for onMutationExecuted

Includes unit tests, but missing integration tests, which will be included in a subsequent PR once the backend changes are completed. Also fixes a typo on an existing file

npm test passes locally

Internal tracking bug: b/436623435

Code sample

Examples of how to use this

import { onMutationExecuted } from "firebase-functions/v2/dataconnect";

exports.myfunction = onMutationExecuted(
  {
    service: "service-id",
    connector: "connector-id",
    operation: "mutation-name",
  },
  (event) => { 
    // event.params.service == "service-id" 
    // event.params.connector == "connector-id"
    // event.params.operation == "mutation-name"

    // event.data contains [MutationEventData](https://docs.google.com/document/d/1sCYuBzjhirVTy9Xo2gflGVcKcZyhau9MhkVlbOvC4MI/edit?tab=t.0#bookmark=id.1k7sz3vu87vx)  
  }
);

// Use capture group on operation
exports.myfunctionwithcaptures = onMutationExecuted(
  {
    service: "service-id",
    connector: "connector-id",
    operation: "{operation}",
  },
  (event) => { /** do something */ }
);

// Use wildcard on connector
exports.myfunctionwithwildcards = onMutationExecuted(
  {
    service: "service-id",
    connector: "*",
    operation: "mutation-name",
  },
  (event) => { /** do something */ }
);

See go/fdc-eventarc-functions-sdk for more information

@lisajian lisajian requested a review from taeold August 28, 2025 18:42
@lisajian lisajian marked this pull request as ready for review August 28, 2025 18:42
@lisajian lisajian force-pushed the lj/fdc-support-pt1 branch from 13cbf42 to 52a95a3 Compare October 5, 2025 22:54
@taeold
Copy link
Contributor

taeold commented Oct 7, 2025

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for Firebase Data Connect v2 with the onMutationExecuted trigger. The changes are well-structured, including the new provider, unit tests, and necessary package configuration updates. I've identified a few type safety issues in the new provider implementation concerning the handling of optional parameters, which could lead to runtime errors. I've provided suggestions to address these. Additionally, I've included a recommendation for a minor refactoring to enhance code clarity.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants