@@ -3183,6 +3183,7 @@ describe('REST server tests', () => {
31833183 model Post {
31843184 id Int @id @default(autoincrement())
31853185 title String
3186+ short_title String @unique()
31863187 author User? @relation(fields: [authorId], references: [id])
31873188 authorId Int?
31883189 }
@@ -3195,6 +3196,7 @@ describe('REST server tests', () => {
31953196 endpoint : 'http://localhost/api' ,
31963197 externalIdMapping : {
31973198 User : 'name_source' ,
3199+ Post : 'short_title' ,
31983200 } ,
31993201 } ) ;
32003202 handler = ( args ) => _handler . handleRequest ( { ...args , url : new URL ( `http://localhost/${ args . path } ` ) } ) ;
@@ -3204,7 +3206,9 @@ describe('REST server tests', () => {
32043206 await client . user . create ( {
32053207 data : { id : 1 , name : 'User1' , source : 'a' } ,
32063208 } ) ;
3207-
3209+ await client . post . create ( {
3210+ data : { id : 2 , title : 'Some title' , short_title : 'post-title-2' , authorId : 1 } ,
3211+ } ) ;
32083212 // user is no longer exposed using the `id` field
32093213 let r = await handler ( {
32103214 method : 'get' ,
@@ -3229,13 +3233,13 @@ describe('REST server tests', () => {
32293233 expect ( r . body . data . attributes . name ) . toBe ( 'User1' ) ;
32303234
32313235 await client . post . create ( {
3232- data : { id : 1 , title : 'Title1' , authorId : 1 } ,
3236+ data : { id : 1 , title : 'Title1' , short_title : 'post-title-1' , authorId : 1 } ,
32333237 } ) ;
32343238
32353239 // post is exposed using the `id` field
32363240 r = await handler ( {
32373241 method : 'get' ,
3238- path : '/post/1' ,
3242+ path : '/post/post-title- 1' ,
32393243 query : { include : 'author' } ,
32403244 client,
32413245 } ) ;
0 commit comments