Skip to content

Commit 738357b

Browse files
committed
feat: add education query to GraphQL schema
1 parent 6fc587c commit 738357b

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/app/api/graphql/schema.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const typeDefs = gql`
1111
skillsForUser(userId: ID!): [SkillForUser!]!
1212
companies(userId: ID!, sort: [SortInput!]): [Company!]!
1313
positions(companyIds: [ID!], sort: [SortInput!]): [Position!]!
14+
education(userId: ID!, sort: [SortInput!]): [Education!]!
1415
}
1516
1617
type User {
@@ -73,6 +74,13 @@ const typeDefs = gql`
7374
description: String
7475
}
7576
77+
type Education {
78+
id: ID!
79+
school: String!
80+
degree: String
81+
dateAwarded: String
82+
}
83+
7684
input SortInput {
7785
field: String!
7886
direction: SortDirection!
@@ -137,6 +145,24 @@ const resolvers = {
137145
}, // Include project and skill details
138146
});
139147
},
148+
education: async (
149+
_: string,
150+
{
151+
userId,
152+
sort,
153+
}: { userId: string; sort: Array<{ field: string; direction: "ASC" | "DESC" }> },
154+
) => {
155+
// Map the sort array into Prisma-compatible orderBy
156+
const orderBy =
157+
sort?.map(({ field, direction }) => ({
158+
[field]: direction.toLowerCase(), // Prisma expects lowercase for ASC/DESC
159+
})) || [];
160+
161+
return await prisma.education.findMany({
162+
where: { userId },
163+
orderBy, // Apply sorting
164+
});
165+
},
140166
},
141167
};
142168

0 commit comments

Comments
 (0)