Skip to content

Commit 1415244

Browse files
authored
Merge pull request #217 from hypercerts-org/feat/attestation_resolver_with_schemas
Attestation resolver with schemas
2 parents 32c6505 + 0563d49 commit 1415244

File tree

15 files changed

+214
-95
lines changed

15 files changed

+214
-95
lines changed

schema.graphql

Lines changed: 71 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,11 @@ type Attestation {
8181
"""Encoded data of the attestation"""
8282
data: JSON
8383

84+
"""Schema related to the attestation"""
85+
eas_schema: AttestationSchemaBaseType!
86+
8487
"""Hypercert related to the attestation"""
85-
hypercert: HypercertBaseType
88+
hypercert: HypercertBaseType!
8689
id: ID!
8790

8891
"""Block number at which the attestation was last updated"""
@@ -98,10 +101,40 @@ type Attestation {
98101
resolver: String
99102

100103
"""Unique identifier of the EAS schema used to create the attestation"""
101-
schema: String
104+
schema_uid: String
105+
106+
"""Unique identifier for the attestation on EAS"""
107+
uid: ID
108+
}
109+
110+
type AttestationBaseType {
111+
"""Address of the creator of the attestation"""
112+
attester: String
113+
114+
"""Block number at which the attestation was created"""
115+
creation_block_number: EthBigInt
116+
117+
"""Timestamp at which the attestation was created"""
118+
creation_block_timestamp: EthBigInt
119+
120+
"""Encoded data of the attestation"""
121+
data: JSON
122+
id: ID!
123+
124+
"""Block number at which the attestation was last updated"""
125+
last_update_block_number: EthBigInt
126+
127+
"""Timestamp at which the attestation was last updated"""
128+
last_update_block_timestamp: EthBigInt
129+
130+
"""Address of the recipient of the attestation"""
131+
recipient: String
132+
133+
"""Address of the resolver contract for the attestation"""
134+
resolver: String
102135

103-
"""ID referencing the supported EAS schema in the database"""
104-
supported_schemas_id: ID
136+
"""Unique identifier of the EAS schema used to create the attestation"""
137+
schema_uid: String
105138

106139
"""Unique identifier for the attestation on EAS"""
107140
uid: ID
@@ -114,23 +147,42 @@ input AttestationFetchInput {
114147
"""Supported EAS attestation schemas and their related records"""
115148
type AttestationSchema {
116149
"""Chain ID of the chains where the attestation schema is supported"""
117-
chain_id: EthBigInt
150+
chain_id: EthBigInt!
118151
id: ID!
119152

120153
"""List of attestations related to the attestation schema"""
121-
records: [Attestation!]
154+
records: [AttestationBaseType!]!
122155

123156
"""Address of the resolver contract for the attestation schema"""
124-
resolver: String
157+
resolver: String!
125158

126159
"""Whether the attestation schema is revocable"""
127-
revocable: Boolean
160+
revocable: Boolean!
128161

129162
"""String representation of the attestation schema"""
130-
schema: String
163+
schema: String!
131164

132165
"""Unique identifier for the attestation schema"""
133-
uid: ID
166+
uid: ID!
167+
}
168+
169+
"""Supported EAS attestation schemas and their related records"""
170+
type AttestationSchemaBaseType {
171+
"""Chain ID of the chains where the attestation schema is supported"""
172+
chain_id: EthBigInt!
173+
id: ID!
174+
175+
"""Address of the resolver contract for the attestation schema"""
176+
resolver: String!
177+
178+
"""Whether the attestation schema is revocable"""
179+
revocable: Boolean!
180+
181+
"""String representation of the attestation schema"""
182+
schema: String!
183+
184+
"""Unique identifier for the attestation schema"""
185+
uid: ID!
134186
}
135187

136188
input AttestationSortOptions {
@@ -151,33 +203,36 @@ input AttestationWhereInput {
151203
contract_address: StringSearchOptions
152204
creation_block_number: BigIntSearchOptions
153205
creation_block_timestamp: BigIntSearchOptions
206+
eas_schema: BasicAttestationSchemaWhereInput
154207
hypercerts: BasicHypercertWhereArgs
155-
id: IdSearchOptions
156208
last_update_block_number: BigIntSearchOptions
157209
last_update_block_timestamp: BigIntSearchOptions
158210
metadata: BasicMetadataWhereInput
159211
recipient: StringSearchOptions
160212
resolver: StringSearchOptions
161-
schema: StringSearchOptions
162-
supported_schemas_id: StringSearchOptions
163213
token_id: StringSearchOptions
164214
uid: StringSearchOptions
165215
}
166216

217+
input BasicAttestationSchemaWhereInput {
218+
chain_id: BigIntSearchOptions
219+
resolver: StringSearchOptions
220+
revocable: BooleanSearchOptions
221+
schema: StringSearchOptions
222+
uid: StringSearchOptions
223+
}
224+
167225
input BasicAttestationWhereInput {
168226
attestation: StringSearchOptions
169227
attester: StringSearchOptions
170228
chain_id: BigIntSearchOptions
171229
contract_address: StringSearchOptions
172230
creation_block_number: BigIntSearchOptions
173231
creation_block_timestamp: BigIntSearchOptions
174-
id: IdSearchOptions
175232
last_update_block_number: BigIntSearchOptions
176233
last_update_block_timestamp: BigIntSearchOptions
177234
recipient: StringSearchOptions
178235
resolver: StringSearchOptions
179-
schema: StringSearchOptions
180-
supported_schemas_id: StringSearchOptions
181236
token_id: StringSearchOptions
182237
uid: StringSearchOptions
183238
}

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+
eas_schema?: 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 eas_schema(@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: 10 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,7 @@ export function createBaseResolver<T extends ClassType>(
256257

257258
try {
258259
const queries = this.supabaseCachingService.getAttestations(args);
260+
259261
if (single) {
260262
const res = await queries.data.executeTakeFirst();
261263
return res ? this.parseAttestation(res) : null;

0 commit comments

Comments
 (0)