querySubgraph
Issue an arbitrary GraphQL query against a configured subgraph — the raw escape hatch for reads the SDK doesn’t wrap as a typed action. Pass a codegen TypedDocumentString for full type inference, or a raw GraphQL string.
import { querySubgraph } from "@symmio/trading-core";
const data = await querySubgraph(config, {
document: /* GraphQL */ `
query ($id: ID!) {
quote(id: $id) {
id
partyA
}
}
`,
variables: { id: "42" },
subgraph: "analytics",
});Parameters
documentSubgraphDocument | stringrequiredThe query document — a codegen TypedDocumentString (which infers the result and variables) or a raw GraphQL
string.
variablesVariablesrequiredThe operation variables.
subgraphSymmioSubgraphNamedefault analyticsWhich configured subgraph to query: "analytics" (aggregated data) or "events" (raw on-chain events).
chainIdnumberoptionalOptional chain override.
Returns
TResultThe operation’s data, typed by the document. When document is a TypedDocumentString, the result is fully
inferred; with a raw string it is the generic result type you supply. Transport failures, a GraphQL errors payload,
and empty data all throw (see GraphQL error handling).
Query options
import { querySubgraphQueryOptions } from "@symmio/trading-core";
import { useQuery } from "@tanstack/react-query";
useQuery(
querySubgraphQueryOptions(config, {
document: myDocument,
variables: { id: "42" },
}),
);In React, prefer the useSubgraphQuery hook, which wraps this factory.