firebase / firebase/firebase-tools

Cannot pass in parameters for insertMany mutations in Data Connect

Open
#8,970 11 comments 16 reactions 1 assignee Claimed by @mtr002 View on GitHub
api: dataconnect fr: dataconnect nested input type: feature request
Dominant language
TypeScript
Stars
4.5k
Forks
1.3k
Avg merge
1d 12h
Merged PRs (30d)
84

Description

### [REQUIRED] Environment info

**firebase-tools:** 14.12.0

**Platform:** Ubuntu

### [REQUIRED] Test case

Firebase Data Connect supports batch operations such as `_insertMany` and `_upsertMany`.

However, it doesn't appear to be possible to utilize them in a `mutation`.

Given the following simple schema with one table:

```gql
type Actor @table {
name: String!
}
```

If I want to dynamically batch create `Actor`s by passing in an array of `Actor` data, the following fails:

```gql
mutation CreateActors($actors: [Actor_Data!]!) @auth(level: PUBLIC) {
actor_upsertMany(data: $actors)
}
```

The Data Connect extension throws and error and manually running `firebase dataconnect:sdk:generate` will also not generated the appropriate SDKs:

```
On $actors: cannot use Actor_Data as a variable (please use one variable for each field instead, ex: `{foo: $foo}`)Firebase Data Connect: Compiler
```

Image

### [REQUIRED] Steps to reproduce

Create the test schema outlined above and observe the errors.

### [REQUIRED] Expected behavior

Mutations allow passing in data objects as parameters and using them in `_insertMany` / `_upsertMany` operations.

Firebase [documentation](https://firebase.google.com/docs/data-connect/data-seeding-bulk-operations) has examples of bulk seeding data, but it is with static data only.

### [REQUIRED] Actual behavior

Developer defined mutations cannot dynamically batch insert or upsert using parameters passed into the `mutation`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.