"api object"
Last updated
Last updated
🎥 Watch the "api" object section of the "Server Global State (TanStack/React Query)" style guide video here.
We use a custom-built "api" object, which is essentially a wrapper over React Query (v3), and is tRPC-like in terms of usage.
The frontend routes line up with our backend routes according to our (v2) API schema. (in the comments in the second image below, you can see which backend/Rails controller actions are related to each frontend route)
"api" object (holds "router" objects)
"router" objects (hold "procedures" -- e.g. getSingle, getMany, etc.)
Queries (e.g. getSingle, getMany) (useQuery-wrapped procedures)
Mutations (e.g. create, update, delete) (useMutation-wrapped procedures)
-- Top-level resource (e.g. projects):
-- Nested resource (e.g. production goals -- projects/production_goals)