Skip to content

Commit 32c6505

Browse files
authored
Merge pull request #210 from hypercerts-org/feat/expose-blueprints-hypercerts-relation
Feat/expose blueprints hypercerts relation
2 parents 59dc9f2 + dfa2d7c commit 32c6505

File tree

4 files changed

+40
-3
lines changed

4 files changed

+40
-3
lines changed

commitlintrc.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
1-
export default { extends: ["@commitlint/config-conventional"] };
1+
export default {
2+
extends: ["@commitlint/config-conventional"],
3+
rules: {
4+
"body-max-line-length": [2, "always", 500],
5+
},
6+
};

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)