Skip to content

Commit f3470e0

Browse files
committed
fix: select correct columns when pulling attestations from db
Fixes a bug where the schema_uid was not selected correctly, which resulted in errors when fetching eas_schema using graphql as it's non-nullable.
1 parent b6a5c3d commit f3470e0

File tree

1 file changed

+27
-9
lines changed

1 file changed

+27
-9
lines changed

src/services/SupabaseCachingService.ts

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -93,19 +93,37 @@ export class SupabaseCachingService extends BaseSupabaseService<CachingDatabase>
9393
case "attestations":
9494
return this.db
9595
.selectFrom("attestations")
96-
.selectAll("attestations")
96+
.innerJoin(
97+
"supported_schemas",
98+
"supported_schemas.id",
99+
"attestations.supported_schemas_id",
100+
)
101+
.select([
102+
"attestations.id",
103+
"attestations.uid",
104+
"attestations.chain_id",
105+
"attestations.contract_address",
106+
"attestations.token_id",
107+
"attestations.claims_id",
108+
"attestations.recipient",
109+
"attestations.attester",
110+
"attestations.attestation",
111+
"attestations.data",
112+
"attestations.creation_block_timestamp",
113+
"attestations.creation_block_number",
114+
"attestations.last_update_block_number",
115+
"attestations.last_update_block_timestamp",
116+
"supported_schemas.uid as schema_uid",
117+
])
97118
.$if(args.where?.hypercerts, (qb) =>
98-
qb.innerJoin("claims", "claims.id", "attestations.claims_id"),
119+
qb.innerJoin(
120+
"claims as claims",
121+
"claims.id",
122+
"attestations.claims_id",
123+
),
99124
)
100125
.$if(args.where?.metadata, (qb) =>
101126
qb.innerJoin("metadata", "metadata.uri", "claims.uri"),
102-
)
103-
.$if(args.where?.eas_schema, (qb) =>
104-
qb.innerJoin(
105-
"supported_schemas",
106-
"supported_schemas.id",
107-
"attestations.supported_schemas_id",
108-
),
109127
);
110128
case "eas_schema":
111129
case "supported_schemas":

0 commit comments

Comments
 (0)