graphprotocol / graphprotocol/hypergraph
Async functions for querying public graph
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 22
- Forks
- 12
- PR merge metrics
- No merged PRs in 30d
Description
Currently the only way to query the public graph using a specific schema is to go through Hypergraph's client-side useQuery hook. This works well when you need to modify the data, as we can keep the source of truth for queried data in the same place as modified data.
There are some use-cases where you just need to query for public data but not modify it. For this use case useQuery still works, but it won't work for server-side rendering or ad-hoc queries that run as a result of side-effects.
We should expose the query internals in a separate query(Schema) function.
Query options
Queries require things like the mapping or the space in order to generate the query + filters for a specific schema. We'll need a way to provide these options to the query at query time.
Option 1
We can pass the options to the query directly.
await query(Address, { mapping, spaceId })
Option 2
We can create a QueryClient which accepts options. Not entirely sure but this probably looks similar to hypergraph/react's internal context for spaces.
const client = new HypergraphClient({ mapping, spaceId });
await client.query(Address)
Appendix
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the internal implementation linked in the appendix, packages/hypergraph-react/src/internal/use-query-public.tsx at line 384, and trace how useQuery builds schema queries, mappings, spaces, and filters. Compare the two proposed option designs for supplying mapping and spaceId, then define the async query entry point for server-side rendering and side-effect queries. Done means public graph data can be queried without the React useQuery hook.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100