Skip to content

Commit 2698e5d

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 3ffbb0d commit 2698e5d

1 file changed

Lines changed: 28 additions & 9 deletions

File tree

src/services/SupabaseCachingService.ts

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -91,21 +91,40 @@ export class SupabaseCachingService extends BaseSupabaseService<CachingDatabase>
9191
.selectFrom("claimable_fractions_with_proofs")
9292
.selectAll();
9393
case "attestations":
94+
console.log("args", args.where);
9495
return this.db
9596
.selectFrom("attestations")
96-
.selectAll("attestations")
97+
.innerJoin(
98+
"supported_schemas",
99+
"supported_schemas.id",
100+
"attestations.supported_schemas_id",
101+
)
102+
.select([
103+
"attestations.id",
104+
"attestations.uid",
105+
"attestations.chain_id",
106+
"attestations.contract_address",
107+
"attestations.token_id",
108+
"attestations.claims_id",
109+
"attestations.recipient",
110+
"attestations.attester",
111+
"attestations.attestation",
112+
"attestations.data",
113+
"attestations.creation_block_timestamp",
114+
"attestations.creation_block_number",
115+
"attestations.last_update_block_number",
116+
"attestations.last_update_block_timestamp",
117+
"supported_schemas.uid as schema_uid",
118+
])
97119
.$if(args.where?.hypercerts, (qb) =>
98-
qb.innerJoin("claims", "claims.id", "attestations.claims_id"),
120+
qb.innerJoin(
121+
"claims as claims",
122+
"claims.id",
123+
"attestations.claims_id",
124+
),
99125
)
100126
.$if(args.where?.metadata, (qb) =>
101127
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-
),
109128
);
110129
case "eas_schema":
111130
case "supported_schemas":

0 commit comments

Comments
 (0)