-
Notifications
You must be signed in to change notification settings - Fork 16
enssdk: core client + omnigraph module with gql.tada #1846
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
9fe129a
4880146
cbb6449
2ecd710
2c0ddf3
3d12851
6941fba
3bf16a5
8784e46
35eace6
3107c80
d11d0b9
19a467e
5899005
c2f00eb
197e269
edbe99c
aba31b0
7f1247c
68becd6
ffb3492
0fb593e
8607277
8cb8370
d232132
9d47046
94714f2
fdafe2f
6d2578e
26313d3
31471da
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "enssdk": minor | ||
| --- | ||
|
|
||
| add core client factory with viem-style extend() and omnigraph module with gql.tada typed queries |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,7 @@ dist | |
|
|
||
| # Ponder | ||
| generated | ||
| !packages/enssdk/src/omnigraph/generated/ | ||
| .ponder | ||
|
|
||
| #jetbrains elements | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| import { writeFile } from "node:fs/promises"; | ||
| import { resolve } from "node:path"; | ||
| import { fileURLToPath } from "node:url"; | ||
|
|
||
| import { lexicographicSortSchema, printSchema } from "graphql"; | ||
|
|
||
| import { makeLogger } from "@/lib/logger"; | ||
|
|
||
shrugs marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| const logger = makeLogger("write-graphql-schema"); | ||
|
|
||
| const MONOREPO_ROOT = resolve(import.meta.dirname, "../../../../../"); | ||
| const ENSSDK_ROOT = resolve(MONOREPO_ROOT, "packages/enssdk/"); | ||
| const OUTPUT_PATH = resolve(ENSSDK_ROOT, "src/omnigraph/generated/schema.graphql"); | ||
shrugs marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| async function _writeGraphQLSchema() { | ||
| const { schema } = await import("@/graphql-api/schema"); | ||
| const schemaAsString = printSchema(lexicographicSortSchema(schema)); | ||
|
|
||
| await writeFile(OUTPUT_PATH, schemaAsString); | ||
shrugs marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| /** | ||
| * Attempts to write the GraphQL Schema, swallowing any errors. | ||
| */ | ||
| export async function writeGraphQLSchema() { | ||
| try { | ||
| await _writeGraphQLSchema(); | ||
| logger.info(`Wrote SDL to ${OUTPUT_PATH}`); | ||
| } catch (error) { | ||
| logger.warn(error, `Unable to write SDL to ${OUTPUT_PATH}`); | ||
| } | ||
shrugs marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
shrugs marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| // when executed directly (`pnpm generate:gqlschema`), write generated schema and produce an exit code | ||
| if (resolve(process.argv[1]) === fileURLToPath(import.meta.url)) { | ||
| try { | ||
| await _writeGraphQLSchema(); | ||
| console.log(`Wrote SDL to ${OUTPUT_PATH}`); | ||
| process.exit(0); | ||
| } catch (error) { | ||
| console.error(error); | ||
| process.exit(1); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| MIT License | ||
|
|
||
| Copyright (c) 2025 NameHash | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| SOFTWARE. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # enscli | ||
|
|
||
| This package name is reserved for the [ENSNode](https://ensnode.io) project by [NameHash Labs](https://namehashlabs.org). | ||
|
|
||
| For more information, visit [ensnode.io](https://ensnode.io). |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| { | ||
| "private": true, | ||
shrugs marked this conversation as resolved.
Show resolved
Hide resolved
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Happy to make this public? Please ignore if you think not the right time for some reason.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we can't publish the |
||
| "name": "enscli", | ||
| "version": "1.9.0", | ||
| "description": "Reserved for the ENSNode project by NameHash Labs. See https://ensnode.io", | ||
| "repository": { | ||
shrugs marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "type": "git", | ||
| "url": "https://github.com/namehash/ensnode.git", | ||
| "directory": "packages/enscli" | ||
| }, | ||
| "license": "MIT", | ||
| "homepage": "https://ensnode.io" | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| MIT License | ||
|
|
||
| Copyright (c) 2025 NameHash | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| SOFTWARE. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # enskit | ||
|
|
||
| This package name is reserved for the [ENSNode](https://ensnode.io) project by [NameHash Labs](https://namehashlabs.org). | ||
|
|
||
| For more information, visit [ensnode.io](https://ensnode.io). |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| { | ||
| "name": "enskit", | ||
shrugs marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "version": "1.9.0", | ||
| "description": "Reserved for the ENSNode project by NameHash Labs. See https://ensnode.io", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "https://github.com/namehash/ensnode.git", | ||
| "directory": "packages/enskit" | ||
| }, | ||
| "license": "MIT", | ||
| "homepage": "https://ensnode.io" | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| MIT License | ||
|
|
||
| Copyright (c) 2025 NameHash | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| SOFTWARE. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| # enssdk | ||
|
|
||
| The foundational ENS developer library. Isomorphic, tree-shakable, with composable modules via subpath exports. | ||
|
|
||
| Learn more about [ENSNode](https://ensnode.io/) from [the ENSNode docs](https://ensnode.io/docs). | ||
|
|
||
| ## Installation | ||
|
|
||
| ```bash | ||
| npm install enssdk | ||
| ``` | ||
|
|
||
| ## Usage | ||
shrugs marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| ### Core Client | ||
|
|
||
| ```typescript | ||
| import { createEnsNodeClient } from "enssdk/core"; | ||
|
|
||
| const client = createEnsNodeClient({ url: "https://api.alpha.ensnode.io" }); | ||
| ``` | ||
|
|
||
| ### Omnigraph (Typed GraphQL) | ||
|
|
||
| ```typescript | ||
| import { createEnsNodeClient } from "enssdk/core"; | ||
| import { omnigraph, graphql } from "enssdk/omnigraph"; | ||
|
|
||
| const client = createEnsNodeClient({ url: "https://api.alpha.ensnode.io" }) | ||
| .extend(omnigraph); | ||
|
|
||
| const MyQuery = graphql(` | ||
| query MyQuery($name: Name!) { | ||
| domain(by: { name: $name }) { | ||
| name | ||
| registration { expiry } | ||
| } | ||
| } | ||
| `); | ||
|
|
||
| const result = await client.omnigraph.query({ | ||
| query: MyQuery, | ||
| variables: { name: "nick.eth" }, | ||
| }); | ||
| ``` | ||
|
|
||
| Modules are composable via `extend()` — only import what you use. | ||
|
|
||
| ## License | ||
|
|
||
| Licensed under the MIT License, Copyright © 2025-present [NameHash Labs](https://namehashlabs.org). | ||
|
|
||
| See [LICENSE](./LICENSE) for more information. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "$schema": "https://biomejs.dev/schemas/2.3.2/schema.json", | ||
| "extends": "//", | ||
| "files": { | ||
| "includes": ["**", "!src/omnigraph/generated"] | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.