fabric-sdk
Skill646 starsChanged 56 days agoMITView on GitHub
How to query Fabric data from a running app through the Rayfin connectors client. Use getRayfinClient().connectors.<name>.executeQuery to run DAX against a semantic model, and toQueryResult to normalize the response.
10 other projects use a version of this.
Adopted by
Most recently taken up by
- microsoft/ignite26-PREL40word for word, first seen Nov 22, 2026
- microsoft/awesome-rayfintheir own version, first seen Nov 15, 2026
- microsoft/DataHub-App-for-Microsoft-Copilot-Agents-Cowork-and-Autopilotstheir own version, first seen Nov 8, 2026
- microsoft/ValueLens-for-Microsoft-Copilottheir own version, first seen Oct 25, 2026
- microsoft/ConsumptionCentral-for-Microsoft-Copilottheir own version, first seen Oct 25, 2026
- microsoft/frontiertour27-LTG291-turn-your-data-into-production-apps-with-rayfintheir own version, first seen Oct 17, 2026
Other versions10 projects use a version of this.
Word for word · 1
- microsoft/ignite26-PREL40★ 3100% same
Edited · 0
None found.
Wrote their own version · 9
- microsoft/awesome-rayfin★ 116same name
- microsoft/ConsumptionCentral-for-Microsoft-Copilot★ 36same name
- microsoft/ValueLens-for-Microsoft-Copilot★ 23same name
- microsoft/AnalyticsHub-Dashboard★ 16same name
- microsoft/DataHub-App-for-Microsoft-Copilot-Agents-Cowork-and-Autopilots★ 16same name
- microsoft/aitour27-LTG291-turn-your-data-into-production-apps-with-rayfin★ 3same name
- microsoft/frontiertour27-LTG291-turn-your-data-into-production-apps-with-rayfin★ 3same name
- microsoft/aitour27-BRK390-building-ai-applications-with-microsoft-databases-and-fabric★ 1same name
- microsoft/frontiertour27-BRK390-building-ai-applications-with-microsoft-databases-and-fabric★ 1same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository76 other files it gives its agents.
- common/config/typedoc/AGENTS.mdAGENTS.md
- docs/site/AGENTS.mdAGENTS.md
- .github/skills/react-best-practices/AGENTS.mdAGENTS.md
- packages/docgen/AGENTS.mdAGENTS.md
- packages/guide/AGENTS.mdAGENTS.md
- packages/host-docs/AGENTS.mdAGENTS.md
- packages/tools/AGENTS.mdAGENTS.md
- packages/tools/cli/AGENTS.mdAGENTS.md
- packages/tools/cli/assets/agent-files/AGENTS.mdAGENTS.md
- packages/tools/common/AGENTS.mdAGENTS.md
- packages/tools/docs-lib/AGENTS.mdAGENTS.md
- packages/tools/mcp/AGENTS.mdAGENTS.md
- packages/tools/vscode/AGENTS.mdAGENTS.md
- packages/typescript-sdk/AGENTS.mdAGENTS.md
- packages/typescript-sdk/auth/AGENTS.mdAGENTS.md
- packages/typescript-sdk/core/AGENTS.mdAGENTS.md
- packages/typescript-sdk/data/AGENTS.mdAGENTS.md
- packages/typescript-sdk/storage/AGENTS.mdAGENTS.md
- packages/udf/udf-worker-extension/AGENTS.mdAGENTS.md
- samples/data-app/AGENTS.mdAGENTS.md
- samples/getting-started-auth/AGENTS.mdAGENTS.md
- samples/notes-app/AGENTS.mdAGENTS.md
- samples/todo-app/AGENTS.mdAGENTS.md
- samples/universal-app/template/AGENTS.mdAGENTS.md
- samples/welcome-app-react-auth/AGENTS.mdAGENTS.md
- samples/welcome-app-react-no-auth/AGENTS.mdAGENTS.md
- samples/welcome-app-typescript/AGENTS.mdAGENTS.md
- hotfix-releaseSkill
- launch-vscode-extensionSkill
- openspec-apply-changeSkill
- openspec-archive-changeSkill
- openspec-bulk-archive-changeSkill
- openspec-continue-changeSkill
- openspec-exploreSkill
- openspec-ff-changeSkill
- openspec-new-changeSkill
- openspec-onboardSkill
- openspec-sync-specsSkill
- openspec-verify-changeSkill
- privacy-dfdSkill
- rayfin-cli-uxSkill
- vercel-react-best-practicesSkill
- react-clean-architectureSkill
- run-cli-e2e-locallySkill
- vscode-react-webview-architectureSkill
- vscode-webview-trpc-messagingSkill
- rayfin-connectorsSkill
- rayfin-functionsSkill
- rayfinSkill
- rayfin-storageSkill
- rayfin-getting-startedSkill
- app-designSkill
- app-validationSkill
- dax-authoringSkill
- fabric-cliSkill
- fabric-sdkSkill
- playwright-cliSkill
- query-designSkill
- schema-discoverySkill
- visualsSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
3 rules. 0 are common, 2 are distinctive, and 1 is very specific to this project.
0
Common
Most of the 9 edited versions we read keep these.
2
Distinctive
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 24
Prefer the hook. It normalizes the response and never throws — but it reports failures on two channels, so check error as well as …
- Distinctive: line 124
If you call the client directly, the same two cases arrive as a throw and a resolved error result:
- Distinctive: line 163
If a screen re-queries more than you want, hold the result in state or memoize at the call site.
“Common” is measured: kept by at least 6 in 10 of the 9 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Fabric Data Access at Runtime
Overview
The app reaches Fabric through the Rayfin connectors client. Each connector
is declared in rayfin.yml and surfaced as
getRayfinClient().connectors.<name>, with operations typed by the connector
marker package.
The connector's workspaceId and itemId are injected server-side from
rayfin.yml. The app sends only the query, so no ids reach the bundle and
there is no generated config to keep in sync.
Quick Start
Prefer the hook. It normalizes the response and never throws — but it reports
failures on two channels, so check error as well as data.status:
import { useSemanticModelQuery } from "@/hooks/use-semantic-model-query";
const { data, isLoading, error, refetch } = useSemanticModelQuery({
connection: "sales",
query: 'EVALUATE SUMMARIZECOLUMNS(Product[Category], "Total", [Sales Amount])',
});
if (error) {
// The connector threw: transport, auth, or server failure.
// `data` is undefined here, so checking only data.status renders nothing.
// error.message
} else if (data?.status === "success") {
// data.table.columns — [{ name, dataType }]
// data.table.rows — unknown[][]
} else if (data?.status === "error") {
// The query reached Power BI and failed there.
// data.error.category — "api" | "query" | "network" | "overflow" | "unknown"
// data.error.message
}Drop to the client only when you need something the hook does not expose:
import { toQueryResult } from "@microsoft/rayfin-connector-fabric-semanticmodel";
import { getRayfinClient } from "@/lib/rayfin-client";
// `getRayfinClient` is async in this template, so await it into a variable
// first — `await client().connectors` would read `.connectors` off the Promise.
const client = await getRayfinClient();
const response = await client.connectors.sales.executeQuery({
query: "EVALUATE ...",
});
const result = toQueryResult(response);Key Concepts
Declaring connectors
Connectors come from rayfin/rayfin.yml, managed by rayfin connector add. See
AGENTS.md to register one, and the rayfin-connectors skill that add
installs for the YAML schema. AppConnectorsSchema in
packages/frontend/src/lib/connectors.ts types the names; it accepts any string
by default, so adding a connector needs no code change.
Querying
One operation for DAX:
const client = await getRayfinClient();
await client.connectors[name].executeQuery({ query });Each query must contain exactly one EVALUATE statement.
Bounding rows
There is no default row cap, so bound the DAX with an aggregation or TOPN(...).
The connector's executeQuery will also accept an optional
resultSetRowCountLimit alongside query. Prefer that over TOPN(...) when you
want a guard rather than a deliberately ranked subset: exceeding it fails the
query with an overflow error, so a truncated result announces itself, where
TOPN returns a complete-looking partial answer.
useSemanticModelQuery does not forward the field, so from app code shape the
DAX itself. The CLI's invoke accepts it.
The connector throws, the hook does not
This is the one behavior that trips people up.
executeQuery throws on wiring, transport, auth, and server failures. A
query that reaches Power BI and fails there does not throw; it resolves with the
error nested in the response body.
useSemanticModelQuery catches the throw rather than re-throwing, and keeps the
two disjoint, so a hook caller has two channels and each is reachable:
error— what was thrown, surfaced as-is so its status and service code survive.datais cleared when this is set.data.status === "error"— what Power BI returned, already categorised.errorstaysundefinedfor these.
A component that checks only one renders nothing for half its failures. Check both — the order does not matter, because they never both apply:
if (error) return <Error message={error.message} />;
if (data?.status === "error") return <Error message={data.error.message} />;
if (isLoading || !data) return <Spinner />;
// data.status === "success"If you call the client directly, the same two cases arrive as a throw and a resolved error result:
try {
const result = toQueryResult(await connector.executeQuery({ query }));
if (result.status === "error") { /* Power BI rejected the query */ }
} catch (err) {
/* never reached Power BI */
}Result Handling
toQueryResult returns a discriminated union on status. On success the
table has:
columns:Array<{ name: string, dataType: string }>rows:unknown[][], row-major, values aligned withcolumnsby index
// result.table.columns = [{ name: "Product[Name]", dataType: "unknown" },
// { name: "[Sales]", dataType: "unknown" }]
// result.table.rows = [["Widget", 42], ["Gadget", 17]]Do not branch on dataType. It is "unknown" whenever the payload carries
no column metadata, which is the common in-app case: column names are then
inferred from the first row. Supply display types yourself through
columnMetadata and toDataTable.
Because names are inferred from the first row in that fallback, a query whose first row omits a column (or returns no rows) yields no columns for it. Shape the DAX so every column is present in the first row.
Caching
There is none. The connectors client does not cache, and this template does not add one — every call reaches Power BI.
If a screen re-queries more than you want, hold the result in state or memoize at the call site. Don't introduce a shared, process-global store without a per-principal key and a TTL: without the first it serves one user's rows to the next after a sign-in change, and without the second it serves stale rows after a model refresh.
Error Categories
| Category | Meaning | Example |
query | Invalid DAX | "Syntax error at position 18" |
overflow | Row or byte cap exceeded, data truncated | "More than 1000000 rows in a query result" |
api | Auth or dataset-level failure — usually needs you to change something | 401 Unauthorized |
network | The request never left the machine — worth retrying as-is | Connection reset |
unknown | Could not categorize | Parse failure |
These are the categories the connector puts on a returned result
(data.status === "error"). A failure that never reached Power BI — a wiring
mistake, transport, or auth — is thrown instead and arrives on the hook's error,
with the original on error.cause.
overflow means the result is truncated but present. Treat it as a
failure rather than rendering partial data as if it were complete.
Common Patterns
Multiple models
const sales = useSemanticModelQuery({ connection: "sales", query: salesDax });
const inventory = useSemanticModelQuery({ connection: "inventory", query: invDax });Re-running a query
const { data, refetch } = useSemanticModelQuery({ connection: "sales", query });
await refetch();Anti-Patterns
- Don't branch on
dataType— it is"unknown"whenever column metadata was absent and names had to be inferred from the first row. - Don't treat a resolved promise as success — check
status. - Don't send
workspaceIdoritemId— they come fromrayfin.ymlserver-side. - Don't read only one error channel — a thrown failure leaves
dataundefined, so a component that checks onlydata.statusrenders nothing and looks broken. - Don't return unbounded results — there is no default row cap. Bound the DAX with an aggregation or
TOPN(...).
Type Reference
import type {
ExecuteQueryInput,
FabricSemanticModelTabularResponse,
SemanticModelQueryResult,
QueryTable,
QueryColumn,
QueryError,
} from "@microsoft/rayfin-connector-fabric-semanticmodel";For full type definitions, see references/types.md in this skill.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

