firebase / firebase/firebase-tools
Cannot pass in parameters for insertMany mutations in Data Connect
- 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
```
### [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
Assessment
This issue has not been assessed yet.