Skip to content

Commit dfa2d7c

Browse files
committed
feat: expose minted hypercerts on blueprint graphql entity
- Added `hypercerts` field to the Blueprint type in the GraphQL schema. - Updated BlueprintResolver to include a new FieldResolver for fetching hypercerts based on `hypercert_ids`. - Modified the Blueprint type definition to include the new `hypercerts` field - Modified the blueprints type definition to include internal `hypercert_ids` field for data handling.
1 parent 4d11db7 commit dfa2d7c

File tree

3 files changed

+34
-2
lines changed

3 files changed

+34
-2
lines changed

schema.graphql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ type Blueprint {
250250
admins: [User!]!
251251
created_at: String!
252252
form_values: JSON!
253+
hypercerts: GetHypercertsResponse!
253254
id: Float!
254255
minted: Boolean!
255256
minter_address: String!

src/graphql/schemas/resolvers/blueprintResolver.ts

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
import { Args, ObjectType, Query, Resolver } from "type-graphql";
1+
import {
2+
Args,
3+
FieldResolver,
4+
ObjectType,
5+
Query,
6+
Resolver,
7+
Root,
8+
} from "type-graphql";
29
import { createBaseResolver, DataResponse } from "./baseTypes.js";
310
import { Blueprint } from "../typeDefs/blueprintTypeDefs.js";
411
import { GetBlueprintArgs } from "../args/blueprintArgs.js";
@@ -23,11 +30,18 @@ class BlueprintResolver extends BlueprintBaseResolver {
2330
.groupBy("id")
2431
.map((blueprints) => {
2532
const admins = blueprints.map(
26-
({ admin_address, admin_chain_id, avatar, display_name }) => ({
33+
({
34+
admin_address,
35+
admin_chain_id,
36+
avatar,
37+
display_name,
38+
hypercert_ids,
39+
}) => ({
2740
address: admin_address,
2841
chain_id: admin_chain_id,
2942
avatar,
3043
display_name,
44+
hypercert_ids,
3145
}),
3246
);
3347
return {
@@ -41,6 +55,16 @@ class BlueprintResolver extends BlueprintBaseResolver {
4155
count,
4256
};
4357
}
58+
59+
@FieldResolver()
60+
async hypercerts(@Root() blueprint: Blueprint) {
61+
const hypercertIds = blueprint.hypercert_ids;
62+
const { data: hypercerts, count } = await this.getHypercerts({
63+
where: { hypercert_id: { in: hypercertIds } },
64+
});
65+
66+
return { data: hypercerts, count };
67+
}
4468
}
4569

4670
export { BlueprintResolver };

src/graphql/schemas/typeDefs/blueprintTypeDefs.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Field, ObjectType } from "type-graphql";
22
import { GraphQLJSON } from "graphql-scalars";
33
import { User } from "./userTypeDefs.js";
4+
import GetHypercertsResponse from "../resolvers/hypercertResolver.js";
45

56
@ObjectType()
67
class Blueprint {
@@ -21,6 +22,12 @@ class Blueprint {
2122

2223
@Field(() => [User])
2324
admins?: User[];
25+
26+
@Field(() => GetHypercertsResponse)
27+
hypercerts?: GetHypercertsResponse;
28+
29+
// Internal field, not queryable
30+
hypercert_ids?: string[];
2431
}
2532

2633
export { Blueprint };

0 commit comments

Comments
 (0)