-
Notifications
You must be signed in to change notification settings - Fork 8
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
const result = await request<EntityQueryResult>(`${Graph.TESTNET_API_ORIGIN}/graphql`, queryDocument, {