File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments