File tree Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -3,11 +3,13 @@ import { Book } from "../../entity/Book";
33
44export const BookResolvers = {
55 Query : {
6- books : async ( ) => {
6+ books : async ( _ : any , args : { title ?: string } ) => {
77 try {
88 const dataSourceInstance = await dataSource ;
99 const bookRepository = dataSourceInstance . getRepository ( Book ) ;
10- const books = await bookRepository . find ( ) ;
10+ const books = await bookRepository . find ( {
11+ where : args . title ? { title : args . title } : { } ,
12+ } ) ;
1113 return books ;
1214 } catch ( error ) {
1315 console . error ( "Error fetching books:" , error ) ;
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ export const typeDefs = `#graphql
77 type Query {
88 hello: String!
99 dbInfo: String!
10- books: [Book!]!
1110 users: [User!]!
11+ books(title: String): [Book!]!
1212 }
1313` ;
You can’t perform that action at this time.
0 commit comments