Count the edges of each edge type
Read in one request how many edges of each edge type a credential can read, to show which edge types an instance uses.
An app that shows how items link, such as a filter that offers only the edge types in use, needs to know how many edges each one has. One request counts them all, so the app doesn't page through every edge. You need a credential that reads at least one type.
Ask for the counts
List edge types with include=counts. In the TypeScript example, marfa is a TypeScript SDK client.
marfa edge-types list --counts --jsonEach edge type the credential can read gains a count. The answer is the whole list, with no further page.
From the next Marfa release after v0.0.122, marfa edge-types list --counts also prints a count column without --json; in v0.0.122, only --json shows the count.
What a count takes in
A count is the number of edges that List edges answers the same credential for that edge type, paged to its end with no other filter. So a count:
- Includes the edges of items in the bin, as the listing does.
- Leaves out an edge whose from item the credential can't read.
Some edge types get no count:
| When | The answer |
|---|---|
| The credential's edge map doesn't let it read the edge type | The edge type, without a count |
| The credential reaches no type | The list, with no count on any edge type |
The request leaves out include=counts | The list, with no count on any edge type |
include names anything else | 400 validation_error |
A plugin's connector key that reaches a type only through its mapping gets counts.
Read the counts in the overview
Get an overview gives each edge type it lists the same count, and its reverse_name when it has one. It lists only the edge types the credential can read, so every one has a count.
marfa overview prints both for each edge type. An agent reads them from marfa_overview called with no arguments, and can name an edge by its reverse name when it saves an item.
The rules are in the contract, under Edge types in the edges chapter and What a credential can reach in the instance chapter.