You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+1-153Lines changed: 1 addition & 153 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,160 +16,8 @@ Instructions for [Swift Package Manager](https://swift.org/package-manager/) sup
16
16
found in the [SwiftPackageManager.md](SwiftPackageManager.md) Markdown file.
17
17
18
18
## Getting Started
19
-
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.
20
19
21
-
Once you are selected as an allowlist member, you should be able to create a Cloud SQL instance through Firebase Data Connect console.
22
-
23
-
Here's a quick rundown of steps to get you started. Learn more about details at the official [Getting Started documentation](https://firebase.google.com/docs/data-connect/quickstart).
24
-
25
-
### 1. Create a new Data Connect service and Cloud SQL instance.
26
-
* Go to Firebase Console and select Firebase Data Connect from the Left Navigation bar to create a new Data Connect service and a Cloud SQL instance. You have to be in Blaze plan and you can view the details of pricing at https://firebase.google.com/pricing.
27
-
* Select us-central1 region if you want to try out vector search with Data Connect later.
28
-
* Your Cloud SQL instance is now to be provisioned, you can view and manage the instance at the Google Cloud console.
29
-
30
-
### 2. Setup your iOS app and [initialize Firebase](https://firebase.google.com/docs/ios/setup)
31
-
32
-
#### The following steps will guide you to setup your schema and create query operation that you need for your app. The toolings below will help you to test out your query with dummy data and once you are happy with your query, the tools will help generate client code for that query so you can call directly from your app.
33
-
34
-
35
-
### 3. Set up [Firebase CLI](https://firebase.google.com/docs/cli)
36
-
37
-
* If you already have CLI, make sure you always update to the latest version
38
-
```
39
-
npm install -g firebase-tools
40
-
```
41
-
42
-
### 4. Set up VSCode
43
-
You will need VS Code and its Firebase extension (VS Code extension) to automatically generate Swift code for your queries.
44
-
* Install VS Code
45
-
* Download the [extension](https://firebasestorage.googleapis.com/v0/b/firemat-preview-drop/o/vsix%2Ffirebase-vscode-latest.vsix?alt=media) and drag it into the "Extensions" in the Left Navigation bar for installation. Keep in mind double clicking the file won't install.
46
-
* Create a fdc folder where you like to have firebase data connect configuration.
47
-
```
48
-
mkdir fdc
49
-
```
50
-
* Open VS Code from folder you just created
51
-
* Select the Firebase icon on the left and login
52
-
* Click on "Run firebase init" button
53
-
54
-
* Select the first option of Data Connect
55
-
* Enter/Select the project, service and database ID you setup on the console
56
-
* Enter to select the default connector ID and complete the rest of the process
57
-
58
-
### 5. Set up generated SDK location
59
-
In the connector.yaml file, add the following code to enable swift code to be generated.
60
-
61
-
```
62
-
swiftSdk:
63
-
outputDir: "../swift-generated/"
64
-
package: "User"
65
-
```
66
-
* You should see swift code is generated inside the ../swift-generated/User/ folder
67
-
68
-
### 6. Create a schema and generate some dummy data
69
-
* In the schema.gql file, uncomment the schema
70
-
```
71
-
type User @table(key: "uid") {
72
-
uid: String!
73
-
name: String!
74
-
address: String!
75
-
}
76
-
```
77
-
* On top of the schema User, an "Add data" button start showing up, click on it to generate a User_insert.gql file
78
-
* Fill out the fields and click on Run button to run the query to add a user dummy data for testing
79
-
80
-
### 7. Deploy your schema
81
-
* To deploy your schema, you will need your Cloud SQL instance to be ready. You can view the instance at the Cloud Cloud console.
82
-
* Select the Firebase icon on the left and Click on the "Deploy all" button to deploy all the schema and operations to backend.
83
-
* You can now see your schemas on the Firebase Console.
84
-
85
-
### 8. Set up a mutation
86
-
In the mutations.gql file, uncomment the "CreateUser" query.
87
-
* In the CONFIGURATION -> VARIABLES, enter
88
-
```
89
-
{
90
-
"name" : "dummy_name",
91
-
"address" : "dummy_address"
92
-
}
93
-
```
94
-
* In the CONFIGURATION -> AUTHENTICATION, select Run as "Authenticated".
95
-
* Click on the "Run" button above the query.
96
-
* You should see your dummy data is added.
97
-
* Select the Firebase icon on the left and Click on the "Deploy all" button to deploy all the schema and operations to backend.
98
-
* 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.
99
-
100
-
#### At this point, you have the code generated for the queries you need for your app. Now let's see how you can use the generated query code in your iOS app:
101
-
102
-
### 9. Adding the generated package to your app project
103
-
* Go to File -> Add Package Dependencies -> Add Local
104
-
* Navigate to the generated folder and select the "swift-generated/User" folder (You should see a Package.swift file in it).
105
-
106
-
### 10. Calling the generated code from your app
107
-
```
108
-
import FirebaseDataConnect
109
-
import Users //change this to the name of your generated package
110
-
111
-
func executeFDCCreateUserQuery() {
112
-
Task {
113
-
do {
114
-
let result = try await DataConnect.defaultConnectorClient.createUserMutationRef(name: "dummyUserName", address: "dummyUserAddress").execute()
115
-
} catch {
116
-
}
117
-
}
118
-
}
119
-
120
-
```
121
-
122
-
123
-
124
-
125
-
## Development
126
-
127
-
To develop Firebase software in this repository, ensure that you have at least
128
-
the following software:
129
-
130
-
* Xcode 15.2 (or later)
131
-
132
-
### Swift Package Manager
133
-
* To enable test schemes: `./scripts/setup_spm_tests.sh`
134
-
*`open Package.swift` or double click `Package.swift` in Finder.
135
-
* Xcode will open the project
136
-
* Choose a scheme for a library to build or test suite to run
137
-
* Choose a target platform by selecting the run destination along with the scheme
138
-
139
-
### Code Formatting
140
-
141
-
To ensure that the code is formatted consistently, run the script
0 commit comments