Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove the coresdkpackagelocation as it is no longer needed #13218

Merged
merged 3 commits into from
Jul 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 26 additions & 46 deletions FirebaseDataConnect/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,25 @@ Here's a quick rundown of steps to get you started. Learn more about details at
### 1. Create a new Data Connect service and Cloud SQL instance.
* 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.
* Select us-central1 region if you want to try out vector search with Data Connect later.
* Wait for the Cloud SQL instance to be provisioned, you can view and manage the instance at the [Cloud console](https://pantheon.corp.google.com/sql).
* Your Cloud SQL instance is now to be provisioned, you can view and manage the instance at the [Cloud console](https://pantheon.corp.google.com/sql).

### 2. Setup your iOS app and [initialize Firebase](https://firebase.google.com/docs/ios/setup)

### 2. Set up [Firebase CLI](https://firebase.devsite.corp.google.com/docs/cli)
#### 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.


### 3. Set up [Firebase CLI](https://firebase.devsite.corp.google.com/docs/cli)

* If you already have CLI, make sure you always update to the latest version
```
npm install -g firebase-tools
```

### 3. Set up VSCode
### 4. Set up VSCode
You will need VS Code and its Firebase extension (VS Code extension) to automatically generate Swift code for your queries.
* Install VS Code
* 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.
* Create a fdc folder where you like to have firebase configuration.
* Create a fdc folder where you like to have firebase data connect configuration.
```
mkdir fdc
```
Expand All @@ -36,7 +40,17 @@ mkdir fdc
* 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

### 4. Create a schema and generate some dummy data
### 5. Set up generated SDK location
In the connector.yaml file, add the following code to enable swift code to be generated.

```
swiftSdk:
outputDir: "../swift-generated/"
package: "User"
```
* You should see swift code is generated inside the ../swift-generated/User/ folder

### 6. Create a schema and generate some dummy data
* In the schema.gql file, uncomment the schema
```
type User @table(key: "uid") {
Expand All @@ -48,11 +62,12 @@ type User @table(key: "uid") {
* 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

### 5. Deploy your schema
### 7. Deploy your schema
* To deploy your schema, you will need your Cloud SQL instance to be ready. You can view the instance at the [Cloud console](https://pantheon.corp.google.com/sql).
* Select the Firebase icon on the left and Click on the "Deploy all" button to deploy all the schema and operations to backend.
* You can now see your schemas on the Firebase Console.

### 6. Set up a mutation
### 8. Set up a mutation
In the mutations.gql file, uncomment the "CreateUser" query.
* In the CONFIGURATION -> VARIABLES, enter
```
Expand All @@ -64,29 +79,14 @@ In the mutations.gql file, uncomment the "CreateUser" query.
* 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 deplouy all the schema and operations to backend.

### 7. Set up generated SDK location
In the connector.yaml file, add the following code to enable swift code to be generated.

```
swiftSdk:
outputDir: "../swift-generated/"
package: "User"
coreSdkPackageLocation: "file:///Users/[YOURUSERID]/github/firebase-ios-sdk"
```
* You should see swift code is generated inside the ../swift-generated/User/ folder
* The coreSdkPackageLocation should be where you check out the firebase-ios-sdk repo and make sure you check out the "dataconnect" branch because Firebase Data Connect is currently under "dataconnect" branch during Private Preview.

### 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:
* 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.

### 8. Setup your iOS app and [initialize Firebase](https://firebase.google.com/docs/ios/setup)
#### 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:

### 9. Adding the generated package to your app project
* Go to File -> Add Package Dependencies -> Add Local
* Navigate to the generated folder and select it

* Navigate to the generated folder and select the "swift-generated/User" folder (You should see a Package.swift file in it).

### 10. Calling the generated code from your app
```
Expand All @@ -104,23 +104,3 @@ func executeFDCCreateUserQuery() {

```





















Loading