{"slug":"firebase-data-connect","title":"firebase-data-connect","summary":"Use when setting up Data Connect, writing GraphQL queries/mutations, configuring generated SDKs, handling offline, or applying security rules.","platform":"Claude","tags":[],"authorName":"LLM Mart","authorSlug":"llm-mart","score":0,"source":"github","price":null,"verified":false,"createdAt":"2026-08-30T09:57:17.805729Z","repo":{"url":"https://github.com/evanca/flutter-ai-rules","stars":642,"forks":66,"license":"MIT","updatedAt":"2026-09-14T07:51:38Z"},"bodyHtml":"<hr>\n<h2>name: firebase-data-connect\ndescription: \"Use when setting up Data Connect, writing GraphQL queries/mutations, configuring generated SDKs, handling offline, or applying security rules.\"\nlicense: MIT</h2>\n<h1>Firebase Data Connect Skill</h1>\n<p>This skill defines how to correctly use Firebase Data Connect in Flutter applications.</p>\n<h2>When to Use</h2>\n<p>Use this skill when:</p>\n<ul>\n<li>Setting up and configuring Firebase Data Connect in a Flutter project.</li>\n<li>Designing schemas, queries, and mutations for Data Connect.</li>\n<li>Implementing generated SDK calls for typed queries and mutations.</li>\n<li>Handling network failures, data inconsistencies, and offline scenarios.</li>\n<li>Applying security and performance best practices.</li>\n</ul>\n<hr>\n<h2>1. Setup and Configuration</h2>\n<h3>Step 1: Install the package</h3>\n<pre><code>flutter pub add firebase_data_connect\n</code></pre>\n<h3>Step 2: Import and initialize</h3>\n<pre><code>import 'package:firebase_data_connect/firebase_data_connect.dart';\nimport 'package:firebase_core/firebase_core.dart';\nimport 'firebase_options.dart';\n\nawait Firebase.initializeApp(\n  options: DefaultFirebaseOptions.currentPlatform,\n);\n</code></pre>\n<h3>Step 3: Define a schema in <code>dataconnect/schema/schema.gql</code></h3>\n<pre><code>type Movie @table {\n  id: UUID! @default(expr: \"uuidV4()\")\n  title: String!\n  releaseYear: Int\n  genre: String\n  rating: Float\n  description: String\n}\n</code></pre>\n<h3>Step 4: Define queries and mutations in <code>dataconnect/connector/queries.gql</code></h3>\n<pre><code>query ListMovies @auth(level: PUBLIC) {\n  movies {\n    id\n    title\n    releaseYear\n    genre\n    rating\n  }\n}\n\nmutation CreateMovie($title: String!, $releaseYear: Int, $genre: String) @auth(level: USER) {\n  movie_insert(data: {\n    title: $title\n    releaseYear: $releaseYear\n    genre: $genre\n  })\n}\n\nmutation DeleteMovie($id: UUID!) @auth(level: USER) {\n  movie_delete(id: $id)\n}\n</code></pre>\n<h3>Step 5: Generate the typed Flutter SDK</h3>\n<pre><code>flutterfire generate\n</code></pre>\n<p>This produces typed Dart classes for each query and mutation.</p>\n<p><strong>Platform support:</strong></p>\n<table>\n<thead>\n<tr>\n<th>Platform</th>\n<th>Support</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>iOS</td>\n<td>Full</td>\n</tr>\n<tr>\n<td>Android</td>\n<td>Full</td>\n</tr>\n<tr>\n<td>Web</td>\n<td>Full</td>\n</tr>\n<tr>\n<td>Other platforms</td>\n<td>Not supported</td>\n</tr>\n</tbody>\n</table>\n<hr>\n<h2>2. Executing Queries and Mutations</h2>\n<p>Use the generated SDK to execute typed queries and mutations:</p>\n<pre><code>// Execute a query\nfinal result = await ListMoviesQuery().execute();\nfinal movies = result.data.movies;\n\n// Execute a mutation\nawait CreateMovieMutation(title: 'Inception', releaseYear: 2010, genre: 'Sci-Fi')\n    .execute();\n\n// Delete by ID\nawait DeleteMovieMutation(id: movieId).execute();\n</code></pre>\n<h3>Real-Time Listeners</h3>\n<p>Subscribe to query changes for live updates:</p>\n<pre><code>final subscription = ListMoviesQuery().subscribe();\nsubscription.listen((result) {\n  final movies = result.data.movies;\n  // Update UI with latest movie list\n});\n</code></pre>\n<hr>\n<h2>3. Performance and Caching</h2>\n<ul>\n<li>Design efficient queries requesting only the fields needed to minimize data transfer.</li>\n<li>Implement <strong>pagination</strong> for large datasets:\n<pre><code>query ListMoviesPaginated($limit: Int!, $offset: Int!) @auth(level: PUBLIC) {\n  movies(limit: $limit, offset: $offset) {\n    id\n    title\n    releaseYear\n  }\n}\n</code></pre>\n</li>\n<li>Use real-time listeners judiciously to avoid unnecessary network usage.</li>\n<li>Consider <strong>offline capabilities</strong> for critical app functionality by caching query results locally.</li>\n</ul>\n<hr>\n<h2>4. Error Handling</h2>\n<p>Wrap Data Connect calls in try/catch to handle network and validation errors:</p>\n<pre><code>try {\n  final result = await ListMoviesQuery().execute();\n  return result.data.movies;\n} on FirebaseException catch (e) {\n  if (e.code == 'unavailable') {\n    // Handle offline — return cached data\n    return _localCache.getMovies();\n  }\n  rethrow;\n}\n</code></pre>\n<ul>\n<li>Implement <strong>retry logic</strong> with exponential backoff for transient connection errors.</li>\n<li>Provide meaningful error messages for data validation failures.</li>\n<li>Monitor error rates and investigate recurring issues.</li>\n</ul>\n<hr>\n<h2>5. Security</h2>\n<ul>\n<li>Use <code>@auth</code> directives in schema to control access levels (<code>PUBLIC</code>, <code>USER</code>, <code>NO_ACCESS</code>).</li>\n<li>Integrate <strong>Firebase Authentication</strong> for user-based access control.</li>\n<li>Validate data on both client and server sides.</li>\n<li>Follow data privacy best practices when handling user information.</li>\n</ul>\n<hr>\n<h2>References</h2>\n<ul>\n<li><a href=\"https://firebase.google.com/docs/data-connect\">Firebase Data Connect documentation</a></li>\n<li><a href=\"https://firebase.google.com/docs/data-connect/flutter-sdk\">Data Connect Flutter SDK reference</a></li>\n</ul>\n","files":[{"path":"SKILL.md","sizeBytes":4372,"isText":true}],"reviewScore":null,"reviewSummary":null,"trust":{"provenance":"trusted-source-unreviewed","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow.","bodySource":null},"bodyLocked":false,"purchaseUrl":null,"sourceUrl":null,"report":{"provenance":"trusted-source-unreviewed","screen":{"ran":true,"outcome":"clean","suspicious":0,"notes":0,"hiddenCharacters":false},"virusScan":{"engine":"clamav","status":"clean","scannedAt":"2026-08-30T09:58:19.871968Z","sha256":"2E06050EBB7C324A467174E9F5EFA2DED0BF73BB75B92D7D9A69443D889C511A","sizeBytes":1965},"review":null,"source":{"repositoryUrl":"https://github.com/evanca/flutter-ai-rules","path":"skills/firebase-data-connect","license":"MIT","commit":"7b9cce235714ae17acbae896b1e8c8627e128f4c","subtreeSha":"33C32DD39821F2B0CDB6F51A43D336BEC5AE16C9318C0E8E369EBE0965AA0D90","lastSyncedAt":"2026-09-22T13:50:26.675606Z"},"reviewedAt":"2026-08-30T10:14:03.555297Z","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow."},"install":[{"target":"skills-cli","command":"npx skills add https://github.com/evanca/flutter-ai-rules/tree/main/skills/firebase-data-connect"},{"target":"claude-code","command":"claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install evanca-flutter-ai-rules@llmmart"},{"target":"git","command":"git clone https://github.com/evanca/flutter-ai-rules.git"}]}