Skip to content

Commit 536a274

Browse files
committed
feat(attestations): fetch attestations based on schema
Updates Attestation resolver, input and args to support fetching attestations based on schema data. This enables queries based on schema uids
1 parent 32c6505 commit 536a274

File tree

13 files changed

+140
-79
lines changed

13 files changed

+140
-79
lines changed

src/__generated__/routes/routes.ts

Lines changed: 13 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/__generated__/swagger.json

Lines changed: 26 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/graphql/schemas/args/attestationArgs.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@ import { BasicHypercertWhereArgs } from "../inputs/hypercertsInput.js";
66
import type { OrderOptions } from "../inputs/orderOptions.js";
77
import type { Attestation } from "../typeDefs/attestationTypeDefs.js";
88
import { AttestationSortOptions } from "../inputs/sortOptions.js";
9+
import { BasicAttestationSchemaWhereInput } from "../inputs/attestationSchemaInput.js";
910

1011
@InputType()
1112
class AttestationWhereInput extends BasicAttestationWhereInput {
1213
@Field(() => BasicHypercertWhereArgs, { nullable: true })
1314
hypercerts?: BasicHypercertWhereArgs;
1415
@Field(() => BasicMetadataWhereInput, { nullable: true })
1516
metadata?: BasicMetadataWhereInput;
17+
@Field(() => BasicAttestationSchemaWhereInput, { nullable: true })
18+
supported_schemas?: BasicAttestationSchemaWhereInput;
1619
}
1720

1821
@InputType()

src/graphql/schemas/inputs/attestationInput.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,12 @@
11
import { Field, InputType } from "type-graphql";
22
import type { WhereOptions } from "./whereOptions.js";
3-
import {
4-
IdSearchOptions,
5-
BigIntSearchOptions,
6-
StringSearchOptions,
7-
} from "./searchOptions.js";
3+
import { BigIntSearchOptions, StringSearchOptions } from "./searchOptions.js";
84
import type { Attestation } from "../typeDefs/attestationTypeDefs.js";
95

106
@InputType()
117
export class BasicAttestationWhereInput implements WhereOptions<Attestation> {
12-
@Field(() => IdSearchOptions, { nullable: true })
13-
id?: IdSearchOptions;
148
@Field(() => StringSearchOptions, { nullable: true })
159
uid?: StringSearchOptions;
16-
@Field(() => StringSearchOptions, { nullable: true })
17-
supported_schemas_id?: StringSearchOptions;
1810
@Field(() => BigIntSearchOptions, { nullable: true })
1911
creation_block_timestamp?: BigIntSearchOptions;
2012
@Field(() => BigIntSearchOptions, { nullable: true })
@@ -30,8 +22,6 @@ export class BasicAttestationWhereInput implements WhereOptions<Attestation> {
3022
@Field(() => StringSearchOptions, { nullable: true })
3123
resolver?: StringSearchOptions;
3224
@Field(() => StringSearchOptions, { nullable: true })
33-
schema?: StringSearchOptions;
34-
@Field(() => StringSearchOptions, { nullable: true })
3525
attestation?: StringSearchOptions;
3626
@Field(() => BigIntSearchOptions, { nullable: true })
3727
chain_id?: BigIntSearchOptions;

src/graphql/schemas/inputs/attestationSchemaInput.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
import { Field, InputType } from "type-graphql";
2-
import type { WhereOptions } from "./whereOptions.js";
2+
import type { AttestationSchema } from "../typeDefs/attestationSchemaTypeDefs.js";
33
import {
4-
BooleanSearchOptions,
5-
IdSearchOptions,
64
BigIntSearchOptions,
5+
BooleanSearchOptions,
76
StringSearchOptions,
87
} from "./searchOptions.js";
9-
import type { AttestationSchema } from "../typeDefs/attestationSchemaTypeDefs.js";
8+
import type { WhereOptions } from "./whereOptions.js";
109

1110
@InputType()
1211
export class BasicAttestationSchemaWhereInput
1312
implements WhereOptions<AttestationSchema>
1413
{
15-
@Field(() => IdSearchOptions, { nullable: true })
16-
id?: IdSearchOptions | null;
1714
@Field(() => StringSearchOptions, { nullable: true })
1815
uid?: StringSearchOptions | null;
1916
@Field(() => BigIntSearchOptions, { nullable: true })

src/graphql/schemas/resolvers/attestationResolver.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,20 @@ class AttestationResolver extends AttestationBaseResolver {
5454
true,
5555
);
5656
}
57+
58+
@FieldResolver()
59+
async supported_schemas(@Root() attestation: Attestation) {
60+
if (!attestation.schema_uid) return;
61+
62+
return await this.getAttestationSchemas(
63+
{
64+
where: {
65+
uid: { eq: attestation.schema_uid },
66+
},
67+
},
68+
true,
69+
);
70+
}
5771
}
5872

5973
export { AttestationResolver };

src/graphql/schemas/resolvers/attestationSchemaResolver.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ import { GetAttestationSchemasArgs } from "../args/attestationSchemaArgs.js";
1111
import { createBaseResolver, DataResponse } from "./baseTypes.js";
1212

1313
@ObjectType()
14-
class GetAttestationsSchemaResponse extends DataResponse(AttestationSchema) {}
14+
export default class GetAttestationsSchemaResponse extends DataResponse(
15+
AttestationSchema,
16+
) {}
1517

1618
const AttestationSchemaBaseResolver = createBaseResolver("attestationSchema");
1719

src/graphql/schemas/resolvers/baseTypes.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1-
import { type ClassType, Field, Int, Resolver, ObjectType } from "type-graphql";
2-
import { SupabaseDataService } from "../../../services/SupabaseDataService.js";
31
import { container } from "tsyringe";
2+
import { type ClassType, Field, Int, ObjectType, Resolver } from "type-graphql";
43
import { SupabaseCachingService } from "../../../services/SupabaseCachingService.js";
5-
import { GetMetadataArgs } from "../args/metadataArgs.js";
6-
import { GetContractsArgs } from "../args/contractArgs.js";
7-
import { GetFractionsArgs } from "../args/fractionArgs.js";
4+
import { SupabaseDataService } from "../../../services/SupabaseDataService.js";
85
import { GetAllowlistRecordsArgs } from "../args/allowlistRecordArgs.js";
9-
import { GetAttestationSchemasArgs } from "../args/attestationSchemaArgs.js";
106
import { GetAttestationsArgs } from "../args/attestationArgs.js";
7+
import { GetAttestationSchemasArgs } from "../args/attestationSchemaArgs.js";
8+
import { GetBlueprintArgs } from "../args/blueprintArgs.js";
9+
import { GetContractsArgs } from "../args/contractArgs.js";
10+
import { GetFractionsArgs } from "../args/fractionArgs.js";
1111
import { GetHypercertsArgs } from "../args/hypercertsArgs.js";
12+
import { GetMetadataArgs } from "../args/metadataArgs.js";
13+
import { GetOrdersArgs } from "../args/orderArgs.js";
1214
import { GetSalesArgs } from "../args/salesArgs.js";
13-
import { GetUserArgs } from "../args/userArgs.js";
14-
import { GetBlueprintArgs } from "../args/blueprintArgs.js";
1515
import { GetSignatureRequestArgs } from "../args/signatureRequestArgs.js";
16+
import { GetUserArgs } from "../args/userArgs.js";
1617

1718
export function DataResponse<TItem extends object>(
1819
TItemClass: ClassType<TItem>,
@@ -256,6 +257,8 @@ export function createBaseResolver<T extends ClassType>(
256257

257258
try {
258259
const queries = this.supabaseCachingService.getAttestations(args);
260+
261+
console.log("GOT QUERY", queries);
259262
if (single) {
260263
const res = await queries.data.executeTakeFirst();
261264
return res ? this.parseAttestation(res) : null;
Lines changed: 6 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,15 @@
1-
import { Field, ID, ObjectType } from "type-graphql";
2-
import { Attestation } from "./attestationTypeDefs.js";
3-
import { BasicTypeDef } from "./baseTypes/basicTypeDef.js";
4-
import { EthBigInt } from "../../scalars/ethBigInt.js";
1+
import { Field, ObjectType } from "type-graphql";
2+
import { AttestationBaseType } from "./baseTypes/attestationBaseType.js";
3+
import { AttestationSchemaBaseType } from "./baseTypes/attestationSchemaBaseType.js";
54

65
@ObjectType({
76
description: "Supported EAS attestation schemas and their related records",
87
})
9-
class AttestationSchema extends BasicTypeDef {
10-
@Field(() => EthBigInt, {
11-
nullable: true,
12-
description:
13-
"Chain ID of the chains where the attestation schema is supported",
14-
})
15-
chain_id?: bigint | number | string;
16-
@Field(() => ID, {
17-
nullable: true,
18-
description: "Unique identifier for the attestation schema",
19-
})
20-
uid?: string;
21-
@Field({
22-
nullable: true,
23-
description: "Address of the resolver contract for the attestation schema",
24-
})
25-
resolver?: string;
26-
@Field({
27-
nullable: true,
28-
description: "Whether the attestation schema is revocable",
29-
})
30-
revocable?: boolean;
31-
@Field({
32-
nullable: true,
33-
description: "String representation of the attestation schema",
34-
})
35-
schema?: string;
36-
37-
@Field(() => [Attestation], {
38-
nullable: true,
8+
class AttestationSchema extends AttestationSchemaBaseType {
9+
@Field(() => [AttestationBaseType], {
3910
description: "List of attestations related to the attestation schema",
4011
})
41-
records?: Attestation[] | null;
12+
records?: AttestationBaseType[] | null;
4213
}
4314

4415
export { AttestationSchema };
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
11
import { Field, ObjectType } from "type-graphql";
22
import { AttestationBaseType } from "./baseTypes/attestationBaseType.js";
33
import { HypercertBaseType } from "./baseTypes/hypercertBaseType.js";
4+
import { AttestationSchemaBaseType } from "./baseTypes/attestationSchemaBaseType.js";
45

56
@ObjectType({
67
description: "Attestation on the Ethereum Attestation Service",
78
simpleResolvers: true,
89
})
910
class Attestation extends AttestationBaseType {
1011
@Field(() => HypercertBaseType, {
11-
nullable: true,
1212
description: "Hypercert related to the attestation",
1313
})
1414
hypercert?: HypercertBaseType;
15+
16+
@Field(() => AttestationSchemaBaseType, {
17+
description: "Schema related to the attestation",
18+
})
19+
supported_schemas?: AttestationSchemaBaseType;
1520
}
1621

1722
export { Attestation };

0 commit comments

Comments
 (0)