-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TanStack Query Firebase + Data Connect
- Loading branch information
1 parent
f0cb9e7
commit b5afb80
Showing
1,034 changed files
with
8,532 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
VITE_FIREBASE_API_KEY="AIzaSyA3vIUtFlnNSuS_wNo5_aTYduLiGNeSzdE" | ||
VITE_FIREBASE_AUTH_DOMAIN="fdc-movies-app.firebaseapp.com" | ||
VITE_FIREBASE_PROJECT_ID="fdc-movies-app" | ||
VITE_FIREBASE_STORAGE_BUCKET="fdc-movies-app.firebasestorage.app" | ||
VITE_FIREBASE_MESSAGING_SENDER_ID="154156738817" | ||
VITE_FIREBASE_APP_ID="1:154156738817:web:77e3a7c25126f8991a5300" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"schema":["../dataconnect/schema/**/*.gql","../dataconnect/.dataconnect/**/*.gql"],"document":["../dataconnect/connector/**/*.gql"]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"projects": { | ||
"default": "fdc-movies-app" | ||
}, | ||
"targets": {}, | ||
"etags": {} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
lerna-debug.log* | ||
|
||
node_modules | ||
dist | ||
dist-ssr | ||
*.local | ||
|
||
# Editor directories and files | ||
.vscode/* | ||
!.vscode/extensions.json | ||
.idea | ||
.DS_Store | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# TanStack Query Firebase + Data Connect | ||
|
||
![alt text](.github/image1.png) | ||
|
||
A react app that leverages `useConnectQuery` and `useConnectMutation` from TanStack Query Firebase to perform CRUD operations to Firebase Data Connect. | ||
|
||
## Final Result | ||
|
||
![alt text](.github/image2.png) |
128 changes: 128 additions & 0 deletions
128
...t/firebase-dataconnect-movies/dataconnect-generated/js/default-connector/esm/index.esm.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
import { getDataConnect, queryRef, executeQuery, mutationRef, executeMutation, validateArgs } from 'firebase/data-connect'; | ||
|
||
export const connectorConfig = { | ||
connector: 'default', | ||
service: 'firebase-dataconnect-movies', | ||
location: 'us-central1' | ||
}; | ||
|
||
export function createMovieRef(dcOrVars, vars) { | ||
const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true); | ||
if('_useGeneratedSdk' in dcInstance) { | ||
dcInstance._useGeneratedSdk(); | ||
} else { | ||
console.error('Please update to the latest version of the Data Connect SDK by running `npm install firebase@dataconnect-preview`.'); | ||
} | ||
return mutationRef(dcInstance, 'CreateMovie', inputVars); | ||
} | ||
export function createMovie(dcOrVars, vars) { | ||
return executeMutation(createMovieRef(dcOrVars, vars)); | ||
} | ||
export function upsertUserRef(dcOrVars, vars) { | ||
const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true); | ||
if('_useGeneratedSdk' in dcInstance) { | ||
dcInstance._useGeneratedSdk(); | ||
} else { | ||
console.error('Please update to the latest version of the Data Connect SDK by running `npm install firebase@dataconnect-preview`.'); | ||
} | ||
return mutationRef(dcInstance, 'UpsertUser', inputVars); | ||
} | ||
export function upsertUser(dcOrVars, vars) { | ||
return executeMutation(upsertUserRef(dcOrVars, vars)); | ||
} | ||
export function deleteMovieRef(dcOrVars, vars) { | ||
const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true); | ||
if('_useGeneratedSdk' in dcInstance) { | ||
dcInstance._useGeneratedSdk(); | ||
} else { | ||
console.error('Please update to the latest version of the Data Connect SDK by running `npm install firebase@dataconnect-preview`.'); | ||
} | ||
return mutationRef(dcInstance, 'DeleteMovie', inputVars); | ||
} | ||
export function deleteMovie(dcOrVars, vars) { | ||
return executeMutation(deleteMovieRef(dcOrVars, vars)); | ||
} | ||
export function addReviewRef(dcOrVars, vars) { | ||
const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true); | ||
if('_useGeneratedSdk' in dcInstance) { | ||
dcInstance._useGeneratedSdk(); | ||
} else { | ||
console.error('Please update to the latest version of the Data Connect SDK by running `npm install firebase@dataconnect-preview`.'); | ||
} | ||
return mutationRef(dcInstance, 'AddReview', inputVars); | ||
} | ||
export function addReview(dcOrVars, vars) { | ||
return executeMutation(addReviewRef(dcOrVars, vars)); | ||
} | ||
export function deleteReviewRef(dcOrVars, vars) { | ||
const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true); | ||
if('_useGeneratedSdk' in dcInstance) { | ||
dcInstance._useGeneratedSdk(); | ||
} else { | ||
console.error('Please update to the latest version of the Data Connect SDK by running `npm install firebase@dataconnect-preview`.'); | ||
} | ||
return mutationRef(dcInstance, 'DeleteReview', inputVars); | ||
} | ||
export function deleteReview(dcOrVars, vars) { | ||
return executeMutation(deleteReviewRef(dcOrVars, vars)); | ||
} | ||
export function listMoviesRef(dc) { | ||
const { dc: dcInstance} = validateArgs(connectorConfig, dc, undefined); | ||
if('_useGeneratedSdk' in dcInstance) { | ||
dcInstance._useGeneratedSdk(); | ||
} else { | ||
console.error('Please update to the latest version of the Data Connect SDK by running `npm install firebase@dataconnect-preview`.'); | ||
} | ||
return queryRef(dcInstance, 'ListMovies'); | ||
} | ||
export function listMovies(dc) { | ||
return executeQuery(listMoviesRef(dc)); | ||
} | ||
export function listUsersRef(dc) { | ||
const { dc: dcInstance} = validateArgs(connectorConfig, dc, undefined); | ||
if('_useGeneratedSdk' in dcInstance) { | ||
dcInstance._useGeneratedSdk(); | ||
} else { | ||
console.error('Please update to the latest version of the Data Connect SDK by running `npm install firebase@dataconnect-preview`.'); | ||
} | ||
return queryRef(dcInstance, 'ListUsers'); | ||
} | ||
export function listUsers(dc) { | ||
return executeQuery(listUsersRef(dc)); | ||
} | ||
export function listUserReviewsRef(dc) { | ||
const { dc: dcInstance} = validateArgs(connectorConfig, dc, undefined); | ||
if('_useGeneratedSdk' in dcInstance) { | ||
dcInstance._useGeneratedSdk(); | ||
} else { | ||
console.error('Please update to the latest version of the Data Connect SDK by running `npm install firebase@dataconnect-preview`.'); | ||
} | ||
return queryRef(dcInstance, 'ListUserReviews'); | ||
} | ||
export function listUserReviews(dc) { | ||
return executeQuery(listUserReviewsRef(dc)); | ||
} | ||
export function getMovieByIdRef(dcOrVars, vars) { | ||
const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true); | ||
if('_useGeneratedSdk' in dcInstance) { | ||
dcInstance._useGeneratedSdk(); | ||
} else { | ||
console.error('Please update to the latest version of the Data Connect SDK by running `npm install firebase@dataconnect-preview`.'); | ||
} | ||
return queryRef(dcInstance, 'GetMovieById', inputVars); | ||
} | ||
export function getMovieById(dcOrVars, vars) { | ||
return executeQuery(getMovieByIdRef(dcOrVars, vars)); | ||
} | ||
export function searchMovieRef(dcOrVars, vars) { | ||
const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars); | ||
if('_useGeneratedSdk' in dcInstance) { | ||
dcInstance._useGeneratedSdk(); | ||
} else { | ||
console.error('Please update to the latest version of the Data Connect SDK by running `npm install firebase@dataconnect-preview`.'); | ||
} | ||
return queryRef(dcInstance, 'SearchMovie', inputVars); | ||
} | ||
export function searchMovie(dcOrVars, vars) { | ||
return executeQuery(searchMovieRef(dcOrVars, vars)); | ||
} |
1 change: 1 addition & 0 deletions
1
...t/firebase-dataconnect-movies/dataconnect-generated/js/default-connector/esm/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"type":"module"} |
149 changes: 149 additions & 0 deletions
149
react/firebase-dataconnect-movies/dataconnect-generated/js/default-connector/index.cjs.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
const { getDataConnect, queryRef, executeQuery, mutationRef, executeMutation, validateArgs } = require('firebase/data-connect'); | ||
|
||
const connectorConfig = { | ||
connector: 'default', | ||
service: 'firebase-dataconnect-movies', | ||
location: 'us-central1' | ||
}; | ||
exports.connectorConfig = connectorConfig; | ||
|
||
function createMovieRef(dcOrVars, vars) { | ||
const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true); | ||
if('_useGeneratedSdk' in dcInstance) { | ||
dcInstance._useGeneratedSdk(); | ||
} else { | ||
console.error('Please update to the latest version of the Data Connect SDK by running `npm install firebase@dataconnect-preview`.'); | ||
} | ||
return mutationRef(dcInstance, 'CreateMovie', inputVars); | ||
} | ||
exports.createMovieRef = createMovieRef; | ||
exports.createMovie = function createMovie(dcOrVars, vars) { | ||
return executeMutation(createMovieRef(dcOrVars, vars)); | ||
}; | ||
|
||
function upsertUserRef(dcOrVars, vars) { | ||
const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true); | ||
if('_useGeneratedSdk' in dcInstance) { | ||
dcInstance._useGeneratedSdk(); | ||
} else { | ||
console.error('Please update to the latest version of the Data Connect SDK by running `npm install firebase@dataconnect-preview`.'); | ||
} | ||
return mutationRef(dcInstance, 'UpsertUser', inputVars); | ||
} | ||
exports.upsertUserRef = upsertUserRef; | ||
exports.upsertUser = function upsertUser(dcOrVars, vars) { | ||
return executeMutation(upsertUserRef(dcOrVars, vars)); | ||
}; | ||
|
||
function deleteMovieRef(dcOrVars, vars) { | ||
const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true); | ||
if('_useGeneratedSdk' in dcInstance) { | ||
dcInstance._useGeneratedSdk(); | ||
} else { | ||
console.error('Please update to the latest version of the Data Connect SDK by running `npm install firebase@dataconnect-preview`.'); | ||
} | ||
return mutationRef(dcInstance, 'DeleteMovie', inputVars); | ||
} | ||
exports.deleteMovieRef = deleteMovieRef; | ||
exports.deleteMovie = function deleteMovie(dcOrVars, vars) { | ||
return executeMutation(deleteMovieRef(dcOrVars, vars)); | ||
}; | ||
|
||
function addReviewRef(dcOrVars, vars) { | ||
const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true); | ||
if('_useGeneratedSdk' in dcInstance) { | ||
dcInstance._useGeneratedSdk(); | ||
} else { | ||
console.error('Please update to the latest version of the Data Connect SDK by running `npm install firebase@dataconnect-preview`.'); | ||
} | ||
return mutationRef(dcInstance, 'AddReview', inputVars); | ||
} | ||
exports.addReviewRef = addReviewRef; | ||
exports.addReview = function addReview(dcOrVars, vars) { | ||
return executeMutation(addReviewRef(dcOrVars, vars)); | ||
}; | ||
|
||
function deleteReviewRef(dcOrVars, vars) { | ||
const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true); | ||
if('_useGeneratedSdk' in dcInstance) { | ||
dcInstance._useGeneratedSdk(); | ||
} else { | ||
console.error('Please update to the latest version of the Data Connect SDK by running `npm install firebase@dataconnect-preview`.'); | ||
} | ||
return mutationRef(dcInstance, 'DeleteReview', inputVars); | ||
} | ||
exports.deleteReviewRef = deleteReviewRef; | ||
exports.deleteReview = function deleteReview(dcOrVars, vars) { | ||
return executeMutation(deleteReviewRef(dcOrVars, vars)); | ||
}; | ||
|
||
function listMoviesRef(dc) { | ||
const { dc: dcInstance} = validateArgs(connectorConfig, dc, undefined); | ||
if('_useGeneratedSdk' in dcInstance) { | ||
dcInstance._useGeneratedSdk(); | ||
} else { | ||
console.error('Please update to the latest version of the Data Connect SDK by running `npm install firebase@dataconnect-preview`.'); | ||
} | ||
return queryRef(dcInstance, 'ListMovies'); | ||
} | ||
exports.listMoviesRef = listMoviesRef; | ||
exports.listMovies = function listMovies(dc) { | ||
return executeQuery(listMoviesRef(dc)); | ||
}; | ||
|
||
function listUsersRef(dc) { | ||
const { dc: dcInstance} = validateArgs(connectorConfig, dc, undefined); | ||
if('_useGeneratedSdk' in dcInstance) { | ||
dcInstance._useGeneratedSdk(); | ||
} else { | ||
console.error('Please update to the latest version of the Data Connect SDK by running `npm install firebase@dataconnect-preview`.'); | ||
} | ||
return queryRef(dcInstance, 'ListUsers'); | ||
} | ||
exports.listUsersRef = listUsersRef; | ||
exports.listUsers = function listUsers(dc) { | ||
return executeQuery(listUsersRef(dc)); | ||
}; | ||
|
||
function listUserReviewsRef(dc) { | ||
const { dc: dcInstance} = validateArgs(connectorConfig, dc, undefined); | ||
if('_useGeneratedSdk' in dcInstance) { | ||
dcInstance._useGeneratedSdk(); | ||
} else { | ||
console.error('Please update to the latest version of the Data Connect SDK by running `npm install firebase@dataconnect-preview`.'); | ||
} | ||
return queryRef(dcInstance, 'ListUserReviews'); | ||
} | ||
exports.listUserReviewsRef = listUserReviewsRef; | ||
exports.listUserReviews = function listUserReviews(dc) { | ||
return executeQuery(listUserReviewsRef(dc)); | ||
}; | ||
|
||
function getMovieByIdRef(dcOrVars, vars) { | ||
const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true); | ||
if('_useGeneratedSdk' in dcInstance) { | ||
dcInstance._useGeneratedSdk(); | ||
} else { | ||
console.error('Please update to the latest version of the Data Connect SDK by running `npm install firebase@dataconnect-preview`.'); | ||
} | ||
return queryRef(dcInstance, 'GetMovieById', inputVars); | ||
} | ||
exports.getMovieByIdRef = getMovieByIdRef; | ||
exports.getMovieById = function getMovieById(dcOrVars, vars) { | ||
return executeQuery(getMovieByIdRef(dcOrVars, vars)); | ||
}; | ||
|
||
function searchMovieRef(dcOrVars, vars) { | ||
const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars); | ||
if('_useGeneratedSdk' in dcInstance) { | ||
dcInstance._useGeneratedSdk(); | ||
} else { | ||
console.error('Please update to the latest version of the Data Connect SDK by running `npm install firebase@dataconnect-preview`.'); | ||
} | ||
return queryRef(dcInstance, 'SearchMovie', inputVars); | ||
} | ||
exports.searchMovieRef = searchMovieRef; | ||
exports.searchMovie = function searchMovie(dcOrVars, vars) { | ||
return executeQuery(searchMovieRef(dcOrVars, vars)); | ||
}; | ||
|
Oops, something went wrong.