Skip to main content

Example queries

Each example below is a complete GraphQL query. See Data types and limits for how values are represented.

Most recent results​

The 20 most recent torque results, newest first:

query RecentResults {
torqueResults(orderBy: [{ createdAt: desc }], limit: 20) {
resultId
createdAt
torque
angle
job
serialNumber
toolSerial
deviceName
stationName
}
}

Results with their traces​

Each result's traces field returns its torque/angle curves, one per bolt, so you can fetch results and curves in one request:

query ResultsWithTraces {
torqueResults(orderBy: [{ createdAt: desc }], limit: 10) {
resultId
createdAt
torque
angle
traces(orderBy: [{ boltNumber: asc }]) {
boltNumber
allValues
}
}
}

allValues is JSON containing the curve's sample arrays. Trace payloads are large; request them only for the results you need, and keep limit small when you include traces.

Traces for one result​

When you already have a resultId, query its traces directly:

query TracesForResult($resultId: Int!) {
torqueTraces(where: { resultId: { _eq: $resultId } }, orderBy: [{ boltNumber: asc }]) {
id
resultId
boltNumber
toolSerial
updatedAt
allValues
}
}

Variables:

{ "resultId": 12345 }

Filter by serial number​

All results recorded against one serial number:

query ResultsForSerial($serial: String!) {
torqueResults(where: { serialNumber: { _eq: $serial } }, orderBy: [{ createdAt: asc }]) {
resultId
createdAt
torque
angle
job
stationName
}
}

Filter by time range and station​

Combine conditions inside where; fields at the same level are combined with AND. Use _and, _or, and _not for anything more complex. Timestamps are ISO 8601 strings; include a time zone offset.

query ShiftResults($stationId: String!, $from: timestamptz!, $to: timestamptz!) {
torqueResults(
where: {
stationId: { _eq: $stationId }
createdAt: { _gte: $from, _lt: $to }
}
orderBy: [{ createdAt: asc }]
) {
resultId
createdAt
torque
angle
toolSerial
}
}

Variables:

{
"stationId": "your-station-id",
"from": "2026-10-13T06:00:00Z",
"to": "2026-10-13T14:00:00Z"
}

Filter by tool or job​

Match any of several values with _in:

query ResultsForToolsAndJobs {
torqueResults(
where: {
toolSerial: { _in: ["TOOL-001", "TOOL-002"] }
job: { _in: [1, 2] }
}
orderBy: [{ createdAt: desc }]
limit: 100
) {
resultId
createdAt
toolSerial
job
torque
}
}

Every filterable field and operator is listed under the TorqueResultBoolExp and TorqueTraceBoolExp inputs.

Count results​

Use torqueResultsAggregate to count matching results without fetching them, for example before paging:

query CountResultsSince($since: timestamptz!) {
torqueResultsAggregate(where: { createdAt: { _gte: $since } }) {
aggregate {
count
}
}
}

Page through large result sets​

Page with limit and offset, always with a stable orderBy. Ordering by resultId gives a stable order:

query ResultsPage($limit: Int!, $offset: Int!) {
torqueResults(orderBy: [{ resultId: asc }], limit: $limit, offset: $offset) {
resultId
createdAt
torque
angle
}
}

To pull new results incrementally, remember the highest resultId you have stored and ask only for results after it:

query ResultsAfter($lastResultId: Int!) {
torqueResults(
where: { resultId: { _gt: $lastResultId } }
orderBy: [{ resultId: asc }]
limit: 500
) {
resultId
createdAt
torque
angle
serialNumber
}
}

Read part of a JSON field​

formattedValue (the raw result payload from the tool) and allValues (the trace curve) are JSON. Pass path to return only part of the value instead of the whole document:

query ResultPayloadPart {
torqueResults(limit: 5, orderBy: [{ createdAt: desc }]) {
resultId
formattedValue(path: "$.pset")
}
}