Concepts
Fetching
How measurement data enters the package
Fetching is the bridge between your app's GraphQL client and the package's normalized measurement records. The package keeps this layer deliberately small: you provide the client and resolved inputs, it returns data that the rest of the pipeline can use.
Inputs
Measurement fetching depends on three main inputs:
| Input | Purpose |
|---|---|
| GraphQL client | lets the package request data without owning your client setup |
| Timeframe | provides the resolved date bounds to fetch |
| Market supply points | describe which supplies and utilities are in scope |
This keeps fetching separate from state management and UI rendering.
Imperative or React Query
The same underlying operation is available in two styles:
fetchMeasurementsfrom@octopus-energy/measurementsfor server code, loaders, tests, and scriptsmeasurementsQueryOptionsfrom@octopus-energy/measurements/react-queryfor TanStack Query usage
Use whichever style fits the part of the app you are building.
Output
Fetching returns MeasurementRecord[]. The records stay normalized so they can
be filtered, grouped, transformed into overview data, transformed into summary
data, or adapted to a custom UI.
Where to go next
- Data model: what measurement records contain
- Measurements API:
fetchMeasurementsand record helpers - React Query API: query option factories
- Server-Render the First View: server prefetching patterns