-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from namehash/docs/graphql
Docs/graphql
- Loading branch information
Showing
3 changed files
with
156 additions
and
157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# graphql info/spec | ||
|
||
## goals | ||
|
||
1. ponder indexer 1:1 equivalency of results as compared to subgraph | ||
1. support for the ~10 well-defined graphql queries sourced from ensjs, ens-app-v3 | ||
2. support for exhaustive collection queries to support snapshot equivalency tool | ||
2. indexer snapshot equivalency via comprehensive graphql diffs | ||
3. proxy equivalency tool | ||
4. 100% ensjs, ens-app-v3 test suites passing via proxy equivalency tool | ||
|
||
## ponder indexer | ||
|
||
the ponder indexer will implement a custom graphql server and support the queries mentioned above. | ||
|
||
initially it should implement the collection queries necessary to support `snapshot-eq` | ||
|
||
notable work includes matching the subgraph's schema, pagination scheme, and complex filter support. | ||
we can likely use [ponder's autogenerated graphql api](https://github.com/ponder-sh/ponder/blob/main/packages/core/src/graphql/index.ts) as a starting point—along with [`drizzle-graphql`'s](https://github.com/drizzle-team/drizzle-graphql/blob/main/src/util/builders/pg.ts#L390)— _perhaps_ shoving them into an LLM to generate logic that more closely matches thegraph's generated schema. it may or may not be easier to remove the table-level metaprogramming because our top-level query fields are well-known, TBD. we'll also want to use dataloader exactly as ponder does. | ||
|
||
we will implement [a hono middleware much like ponder's](https://github.com/ponder-sh/ponder/blob/0a5645ca8dec327b0c21da432ee00810edeb087c/packages/core/src/graphql/middleware.ts#L23) using graphql-yoga to execute the generated schema | ||
|
||
|
||
## well-known queries | ||
|
||
### from ensjs | ||
|
||
- [`getDecodedName`](https://github.com/ensdomains/ensjs/blob/main/packages/ensjs/src/functions/subgraph/getDecodedName.ts) — Gets the full name for a name with unknown labels from the subgraph | ||
- basically: attempts to heal any encoded labels in a provided name using the subgraph | ||
- if name is fully decoded, return | ||
- split name into `n` labels | ||
- for all encoded labels (`[label]`), find all domains by `id` | ||
- hilariously this queries subgraph with `n` `domains(first: 1, where: { id: $label })` queries | ||
- also queries `domain(id: namehash(name))` but i'm not sure why, as it effectively duplicates the above label queries | ||
- in our ideal indexer, this query is replaced with a single `domain(id: namehash(name))` because the api would handle the full extent of the healing logic | ||
- [`getNameHistory`](https://github.com/ensdomains/ensjs/blob/main/packages/ensjs/src/functions/subgraph/getNameHistory.ts) | ||
- basically just all the events associated with a name | ||
- [`getNamesForAddress`](https://github.com/ensdomains/ensjs/blob/main/packages/ensjs/src/functions/subgraph/getNamesForAddress.ts) | ||
- gets all names related to an address via address=registrant,address=owner,address=wrappedOwner,address=resolvedAddress | ||
- supports `searchString` | ||
- supports filter by (current) expiry, by reverse records, by 'empty' domains | ||
- supports order by expiry date, name, labelName, createdAt | ||
- [expiryDate order by](https://github.com/ensdomains/ensjs/blob/main/packages/ensjs/src/functions/subgraph/filters.ts#L707) is an absolutely insane construction | ||
- supports pagination by constructing additional where clauses to exclude previous results | ||
- [`getSubgraphRecords`](https://github.com/ensdomains/ensjs/blob/main/packages/ensjs/src/functions/subgraph/getSubgraphRecords.ts) — Gets the records for a name from the subgraph | ||
- pretty straightforward, allows querying by specific resolver id | ||
- [`getSubgraphRegistrant`](https://github.com/ensdomains/ensjs/blob/main/packages/ensjs/src/functions/subgraph/getSubgraphRegistrant.ts) — Gets the name registrant from the subgraph. | ||
- only supports eth 2ld | ||
- [`getSubnames`](https://github.com/ensdomains/ensjs/blob/main/packages/ensjs/src/functions/subgraph/getSubnames.ts) — Gets the subnames for a name | ||
- supports `searchString` | ||
- supports filter by (current) expiry, by 'empty' domains | ||
- supports order by expiry date, name, labelName, createdAt | ||
- supports pagination by constructing additional where clauses to exclude previous results | ||
|
||
### from ens-app-v3 | ||
|
||
- [`useResolverExists`](https://github.com/ensdomains/ens-app-v3/blob/328692ae832618f8143916c143b7e4cb9e520811/src/hooks/useResolverExists.ts#L27) — straightforward resolver existence check | ||
- [`useRegistrationData`](https://github.com/ensdomains/ens-app-v3/blob/328692ae832618f8143916c143b7e4cb9e520811/src/hooks/useRegistrationData.ts#L31) — registration by id and nameRegistered events | ||
|
Oops, something went wrong.