Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,18 @@ type Domain {

"""Wrapped owner (V1 NameWrapper EOA). Null when not wrapped."""
wrappedOwner: Account

"""The namehash (ERC-137 node) of this domain; the same value as `id`."""
namehash: String!

"""This same domain; `domain { … }` on a Domain resolves to itself."""
domain: Domain!

"""First page of direct subdomains as a connection, ordered by name: at most `first` (default 10, max 100) with `totalCount` and `pageInfo.hasNextPage`. There is no `after` here; page further with `subdomains(first, skip)`."""
subdomainConnection(first: Int = 10): DomainConnection!

"""Most recent events for this domain as a connection: at most `first` (default 10, max 100) with `totalCount` and `pageInfo.hasNextPage`. There is no `after` here; page further with `events` or the root `eventConnection(where: { namehash })`."""
eventsConnection(first: Int = 10): EventConnection!
}

"""An Ethereum account (address)"""
Expand Down Expand Up @@ -687,6 +699,15 @@ type Registration {
"""Timestamp when domain was registered"""
registrationDate: Int!

"""Block number of the registration event."""
blockNumber: Int!

"""Block number of the registration event; the same value as `blockNumber`."""
block: Int!

"""Timestamp of the registration event; the same value as `registrationDate`."""
timestamp: Int!

"""Timestamp when domain expires"""
expiryDate: Int!

Expand Down Expand Up @@ -1290,6 +1311,57 @@ type ResolverDetail {

"""Resource-name associations announced by this resolver (EAC resource naming; emitted on the first role grant per resource)"""
namedResources: [NamedResourceEntry!]!

"""Canonical Domain associated with this resolver (first by namehash). Null when this resolver isn't bound to any name."""
domain: Domain

"""True when the resolver announced itself as record-model (ResolverCreated)."""
recordModel: Boolean!

"""Address record for a coin type (default 60, ETH). ResolverDetail has no name context, so this reads the zero node (0x0): on a record-model resolver that is the resolver-wide default record, on a legacy resolver it is usually empty."""
addr(coinType: Int = 60): String

"""All set addresses across coin types. ResolverDetail has no name context, so this reads the zero node (0x0): on a record-model resolver that is the resolver-wide default record, on a legacy resolver it is usually empty."""
addresses: [CoinAddress!]

"""All set coin types as decimal strings. ResolverDetail has no name context, so this reads the zero node (0x0): on a record-model resolver that is the resolver-wide default record, on a legacy resolver it is usually empty."""
coinTypes: [String!]

"""Content hash. ResolverDetail has no name context, so this reads the zero node (0x0): on a record-model resolver that is the resolver-wide default record, on a legacy resolver it is usually empty."""
contentHash: String

"""Text-record keys (keys only; read values with `text(key:)`). ResolverDetail has no name context, so this reads the zero node (0x0): on a record-model resolver that is the resolver-wide default record, on a legacy resolver it is usually empty."""
texts: [String!]

"""A text record value by key. ResolverDetail has no name context, so this reads the zero node (0x0): on a record-model resolver that is the resolver-wide default record, on a legacy resolver it is usually empty."""
text(key: String!): String

"""Public key record. ResolverDetail has no name context, so this reads the zero node (0x0): on a record-model resolver that is the resolver-wide default record, on a legacy resolver it is usually empty."""
pubkey: Pubkey

"""ABI content types. ResolverDetail has no name context, so this reads the zero node (0x0): on a record-model resolver that is the resolver-wide default record, on a legacy resolver it is usually empty."""
abis: [Int!]

"""Reverse name record. ResolverDetail has no name context, so this reads the zero node (0x0): on a record-model resolver that is the resolver-wide default record, on a legacy resolver it is usually empty."""
reverseName: String

"""Interface implementations. ResolverDetail has no name context, so this reads the zero node (0x0): on a record-model resolver that is the resolver-wide default record, on a legacy resolver it is usually empty."""
interfaces: [InterfaceRecord!]

"""Version counter. ResolverDetail has no name context, so this reads the zero node (0x0): on a record-model resolver that is the resolver-wide default record, on a legacy resolver it is usually empty."""
version: Int

"""Record the zero node resolves through, as a decimal string. ResolverDetail has no name context, so this reads the zero node (0x0): on a record-model resolver that is the resolver-wide default record, on a legacy resolver it is usually empty."""
recordId: String

"""Names bound to the same record as the zero node. ResolverDetail has no name context, so this reads the zero node (0x0): on a record-model resolver that is the resolver-wide default record, on a legacy resolver it is usually empty."""
linkedNames: [LinkedName!]

"""ENSIP-24 data(key) record as 0x-hex bytes. ResolverDetail has no name context, so this reads the zero node (0x0): on a record-model resolver that is the resolver-wide default record, on a legacy resolver it is usually empty."""
data(key: String!): String

"""ENSIP-24 data keys (keys only; read values with `data(key:)`). ResolverDetail has no name context, so this reads the zero node (0x0): on a record-model resolver that is the resolver-wide default record, on a legacy resolver it is usually empty."""
dataKeys: [String!]
}

"""An EAC resource id and the name/record it guards on a resolver. Legacy resolvers announce it per name (Named*Resource); record-model resolvers announce it per setter ARGUMENT (ResourceArgument): `name` is then empty, `recordKey` carries the argument (text/data key, or 0x-hex for interface ids), `coinType` its integer value (coin type or ABI content type), and `recordKind` is derived from the setter roles granted on the resource — one entry per kind, or `argument` before any grant is indexed."""
Expand Down
25 changes: 13 additions & 12 deletions src/api/handler.zig
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,14 @@ pub const GraphQLHandler = struct {
self.introspection_parsed.deinit();
}

/// Walk the parsed operations and validate each root field against the
/// schema. The validator skips meta fields (`__typename`, `__schema`, …)
/// and unknown root field names (those are surfaced separately by the
/// executor as `UnknownRootField`).
fn validateDocumentArgs(self: *GraphQLHandler, document: *const parser.Document) schema_validator_mod.SchemaValidator.Error!void {
/// Validate every operation's selection set against the schema. The
/// validator skips meta fields (`__typename`, `__schema`, …) and unknown
/// root field names (those are surfaced separately by the executor as
/// `UnknownRootField`).
fn validateDocument(self: *GraphQLHandler, allocator: std.mem.Allocator, document: *const parser.Document) schema_validator_mod.SchemaValidator.Error!void {
schema_validator_mod.clearDiag();
for (document.operations) |op| {
for (op.fields) |*field| {
try self.schema_validator.validateRootField(field);
}
for (document.operations) |*op| {
try self.schema_validator.validateOperation(allocator, op, document.fragments);
}
}

Expand Down Expand Up @@ -287,12 +285,13 @@ pub const GraphQLHandler = struct {
std.log.debug("Query complexity: depth={d}, cost={d}", .{ analysis.depth, analysis.cost });

// Schema validation pass — runs against the parsed document before any
// resolver runs. Catches missing required args, unknown args, and
// unknown fields inside input objects. Replaces per-resolver manual
// resolver runs. Catches missing required args, unknown args, unknown
// fields in selection sets and input objects, and fragments on the
// wrong type, at every depth. Replaces per-resolver manual
// checks for the generic-cases (specific InvalidAddress / TooManyNames
// / etc. type errors stay in the resolvers — they need value-level
// context that schema validation can't see).
if (self.validateDocumentArgs(&document)) {} else |val_err| {
if (self.validateDocument(request_alloc, &document)) {} else |val_err| {
self.metrics.recordError();
// Stable message-family prefixes (external detectors match on them and
// on extensions.code); the tail names the offending field/argument and
Expand All @@ -302,6 +301,8 @@ pub const GraphQLHandler = struct {
error.MissingRequiredArg => "Missing required argument",
error.UnknownArgument => "Unknown argument",
error.UnknownInputObjectField => "Unknown field in input object",
error.UnknownField => "Unknown field",
error.InvalidFragmentType => "Invalid fragment",
else => "Query validation failed",
};
var msg_buf: [280]u8 = undefined;
Expand Down
9 changes: 1 addition & 8 deletions src/api/introspection_projection.zig
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,10 @@ pub const Context = struct {
fragments: []const parser.Fragment,
};

const INTROSPECTION_TYPES = [_][]const u8{ "__Schema", "__Type", "__Field", "__InputValue", "__EnumValue", "__Directive" };

fn eql(a: []const u8, b: []const u8) bool {
return std.mem.eql(u8, a, b);
}

fn isIntrospectionTypeName(name: []const u8) bool {
for (INTROSPECTION_TYPES) |t| if (eql(t, name)) return true;
return false;
}

/// The introspection type reached through `field` of `parent` (drives `__typename`).
fn childTypeName(parent: []const u8, field: []const u8) []const u8 {
if (eql(parent, "__Schema")) return if (eql(field, "directives")) "__Directive" else "__Type";
Expand Down Expand Up @@ -66,7 +59,7 @@ pub fn findType(ctx: Context, name: []const u8) ?std.json.Value {
}

fn isFragmentLike(field: *const parser.Field) bool {
return field.fragment_spread != null or (isIntrospectionTypeName(field.name) and field.selections.len > 0 and field.arguments.len == 0);
return field.fragment_spread != null or field.inline_fragment;
}

/// True when the selection asks for anything beyond `name` / `__typename`
Expand Down
Loading
Loading