|
|
1 год назад | |
|---|---|---|
| .. | ||
| Protos | d45aeb7e36 Cleanup, Add OSS license | 1 год назад |
| Sources | 764f26de96 Enable AppCheck | 1 год назад |
| Tests | 8f4087a6eb add scope restrictions | 1 год назад |
| Changelog.md | caa82a27b9 Initial Setup | 1 год назад |
| README.md | 16f42838c2 remove the coresdkpackagelocation as it is no longer needed (#13218) | 1 год назад |
Firebase Data Connect is in Private Preview at no cost for a limited time. Sign up the program at https://firebase.google.com/products/data-connect.
Once you are selected as an allowlist member, you should be able to create a Cloud SQL instance through Firebase Data Connect console.
Here's a quick rundown of steps to get you started. Learn more about details at the official Getting Started documentation.
If you already have CLI, make sure you always update to the latest version
npm install -g firebase-tools
You will need VS Code and its Firebase extension (VS Code extension) to automatically generate Swift code for your queries.
Create a fdc folder where you like to have firebase data connect configuration.
mkdir fdc
Open VS Code from folder you just created
Select the Firebase icon on the left and login
Click on "Run firebase init" button
Select the first option of Data Connect
Enter/Select the project, service and database ID you setup on the console
Enter to select the default connector ID and complete the rest of the process
In the connector.yaml file, add the following code to enable swift code to be generated.
swiftSdk:
outputDir: "../swift-generated/"
package: "User"
In the schema.gql file, uncomment the schema
type User @table(key: "uid") {
uid: String!
name: String!
address: String!
}
On top of the schema User, an "Add data" button start showing up, click on it to generate a User_insert.gql file
Fill out the fields and click on Run button to run the query to add a user dummy data for testing
In the mutations.gql file, uncomment the "CreateUser" query.
In the CONFIGURATION -> VARIABLES, enter
{
"name" : "dummy_name",
"address" : "dummy_address"
}
In the CONFIGURATION -> AUTHENTICATION, select Run as "Authenticated".
Click on the "Run" button above the query.
You should see your dummy data is added.
Select the Firebase icon on the left and Click on the "Deploy all" button to deploy all the schema and operations to backend.
As you see this operation needs authentication, so you will need to be authenticated with Firebase Authentication in your client app when you call this operation in iOS app.
import FirebaseDataConnect
import Users //change this to the name of your generated package
func executeFDCCreateUserQuery() {
Task {
do {
let result = try await DataConnect.defaultConnectorClient.createUserMutationRef(name: "dummyUserName", address: "dummyUserAddress").execute()
} catch {
}
}
}