The Firebase CLI lets you manage your Firebase projects in a local, version-controllable project directory. This includes SQL Connect services in your projects, connectors for those services, and resources like schema, query and mutation sources for each connector. The CLI also lets you install and operate the Firebase SQL Connect emulator. The CLI is an efficient alternative to working in the Firebase console.
For instructions on installing the Firebase CLI experiment for Private Preview program, and SQL Connect-related CLI commands, see the Firebase CLI reference.
This reference guide documents:
- SQL Connect-specific entries in your
firebase.jsonproject configuration file. - SQL Connect configurations in
dataconnect.yamlandconnector.yaml.
Firebase project configuration files
firebase.json configuration reference
Use the dataconnect and emulators.dataconnect keys in your firebase.json
file to configure one or more SQL Connect services and the local
emulator in your project:
{
"dataconnect": {
"source": "dataconnect"
},
"emulators": {
"dataconnect": {
"host": "localhost",
"port": 9399,
"postgresPort": 5432,
"dataDir": "dataconnect/.dataconnect/pgliteData"
}
}
}
The firebase.json file supports the following SQL Connect keys:
dataconnect: Required for SQL Connect projects. Accepts either a single object or an array of objects when your project has multiple services.source: Required. Path to the directory that contains thedataconnect.yamlservice file.predeployandpostdeploy: Optional. Command strings or arrays of commands to run before or after deploying SQL Connect resources.
emulators.dataconnect: Optional configuration for the SQL Connect emulator.host: Optional. Hostname for the emulator. Defaults to"localhost".port: Optional. Port for the SQL Connect emulator. Defaults to9399.postgresPort: Optional. Port for the local PostgreSQL server. Defaults to5432.dataDir: Optional. Directory where the emulator automatically persists local PGLite database data between runs.
dataconnect.yaml configuration reference
The dataconnect.yaml file stores configuration information about the locations
of application schema sources, connector sources, and data source connection
information. The file also serves as a project directory signifier for the
Firebase CLI.
The schemaValidation key controls the level of schema validation performed
when schemas are migrated during deployment. With no value set, in interactive
mode the firebase dataconnect:sql:migrate command prompts you before applying
required compatible changes and then prompts you before running optional strict
changes. For --force and --non-interactive behavior, see
dataconnect:sql:migrate.
When set, the behavior is as follows:
STRICTmode. The database schema must exactly match the application schema before the application schema can be deployed. Any tables or columns that are not used in your SQL Connect schema will be deleted from the database.COMPATIBLEmode. The database schema must be compatible with the application schema before the application schema can be deployed; any additional changes are considered optional. Compatible means that schema migrations are based on the application schema you write. Elements in your database that are not used by your application schema are left unmodified. Therefore, after deployment, your backend may contain unused schemas, tables, and columns.
Values for other keys in this file are explained in the comments below.
# The top-level Firebase SQL Connect YAML file.
# The Firebase SQL Connect API version to target.
# Optional. Defaults to the latest version.
specVersion: string
# The ID of the Firebase SQL Connect service resource.
# Required.
serviceId: string
# The location of the Firebase SQL Connect service.
# Required.
location: string
# Required.
schema:
# Relative path to the directory for schema definitions.
# Recursively loads all .gql files in this directory.
# Required. Typically "./schema" (set by firebase init).
source: string
# Datasource connection information.
# Required.
datasource:
# Required.
postgresql:
# The name of the PostgreSQL database.
# Required.
database: string
cloudSql:
# The ID of the Cloud SQL instance resource.
# Required. For supported PostgreSQL versions, see:
# https://firebase.google.com/docs/sql-connect/manage-services-and-databases#supported-postgres-versions
instanceId: string
# Schema validation mode for schema migrations.
# Optional. If unspecified, migrations prompt for required compatible
# changes and then optional strict changes.
# Set to "STRICT" or "COMPATIBLE".
schemaValidation: string
# Required.
# Relative paths to directories for connector definitions.
# Recursively loads all .gql files in the listed directories.
# All directories specified MUST contain a connector.yaml file.
connectorDirs: [string]
The YAML file assumes a default (but configurable) directory structure of:
./(project root)
/dataconnect
dataconnect.yaml
/schema
*.gql
/example
connector.yaml
*.gql
connector.yaml configuration reference
Use the connector.yaml file to configure the connector ID and SDK generation
options.
# The connector-level YAML file.
# Required. The connector name of the Firebase SQL Connect connector resource.
connectorId: string
# Optional. If not specified, no generated libraries (i.e. type-safe SDKs) will
# be generated.
generate:
# Optional.
javascriptSdk:
# Path to the directory that will be updated with the latest generated
# web TypeScript SDK.
# Required.
outputDir: string
# Name of the Javascript package to be created.
# Required. Example: @dataconnect/generated
package: string
# Path to your package.json directory. If specified, the new generated
# SDK will be installed in this path.
# Optional. If not provided, the package will not be auto-installed for
# you.
packageJsonDir: string
# Enable React framework bindings.
# Optional. Default to false.
react: Boolean
# Enable Angular framework bindings.
# Optional. Default to false.
angular: Boolean
# Enable and configure client-side caching for the generated SDK.
# Optional. If the `clientCache` key is not present, caching is disabled.
clientCache:
# The maximum age allowed for cached results before fetching fresh
# values. A value of "0" means that responses are cached, but the
# client SDK will always fetch fresh values; the cached values are
# only used when CACHE_ONLY is specified to executeQuery() and as the
# initial result returned from subscribe().
# Examples: "0", "30s", "1h30m"
# Optional. Default: "0"
maxAge: string
# Configures how results are to be cached.
# Optional. Only "memory" is allowed for JavaScript SDKs.
storage: string
# Optional.
dartSdk:
# Path to the directory that will be updated with the latest generated
# Flutter Dart SDK.
# Required.
outputDir: string
# Name of the Dart package to be created.
# Required. Example: "dataconnect_generated"
package: string
# Enable and configure client-side caching for the generated SDK.
# Optional. If the `clientCache` key is not present, caching is disabled.
clientCache:
# The maximum age allowed for cached results before fetching fresh
# values. A value of "0" means that responses are cached, but the
# client SDK will always fetch fresh values; the cached values are
# only used when CACHE_ONLY is specified to execute() and as the
# initial result returned from subscribe().
# Examples: "0", "30s", "1h30m"
# Optional. Default: "0"
maxAge: string
# Configures whether results are to be cached in persistent storage
# or in memory ("persistent" or "memory").
# Optional.
# Default: "persistent" for Android and iOS targets, "memory" for web.
storage: string
# Optional.
kotlinSdk:
# Path to the directory that will be updated with the latest generated
# Android SDK.
# Required.
outputDir: string
# Name of the package to be created.
# Required. Example: com.google.firebase.dataconnect.generated
package: string
# Enable and configure client-side caching for the generated SDK.
# Optional. If the `clientCache` key is not present, caching is disabled.
clientCache:
# The maximum age allowed for cached results before fetching fresh
# values. A value of "0" means that responses are cached, but the
# client SDK will always fetch fresh values; the cached values are
# only used when CACHE_ONLY is specified to execute().
# Examples: "0", "30s", "1h30m"
# Optional. Default: "0"
maxAge: string
# Configures whether results are to be cached in persistent storage
# or in memory ("persistent" or "memory").
# Optional. Default: persistent
storage: string
# Optional.
adminNodeSdk:
# Path to the directory that will be updated with the latest generated
# Node Admin SDK.
# Required.
outputDir: string
# Path to your package.json directory. If specified, the new generated
# SDK will be installed in this path.
# Optional. If not provided, the package will not be auto-installed for
# you.
packageJsonDir: string
# Name of the package to be created (for example: @dataconnect/admin-generated).
# Required.
package: string
# Optional.
swiftSdk:
# Path to the directory that will be updated with the latest generated
# iOS Swift SDK.
# Required.
outputDir: string
# Name of the Swift package to be created.
# Required. Example: "FirebaseDataConnectGenerated"
package: string
# Enable and configure client-side caching for the generated SDK.
# Optional. If the `clientCache` key is not present, caching is disabled.
clientCache:
# The maximum age allowed for cached results before fetching fresh
# values. A value of "0" means that responses are cached, but the
# client SDK will always fetch fresh values; the cached values are
# only used when CACHE_ONLY is specified to execute().
# Examples: "0", "30s", "1h30m"
# Optional. Default: "0"
maxAge: string
# Configures whether results are to be cached in persistent storage
# or in memory ("persistent" or "memory").
# Optional. Default: persistent
storage: string