import { PaginationStrategy } from '.' ; import { Helpers as DMMFHelpers , InternalDMMF } from '../dmmf' ; import { keys } from '../utils' ; interface PrismaPaginationArgs { cursor ? : object ; take ? : number ; skip ? : number ; } const prismaPaginationArgsToDmmfArgs = { take : ( ) => ( { name : 'take' , inputType : { type : 'Int' , kind : 'scalar' , isRequired : false , isList : false , isNullable : false , } , } ) , skip : ( ) => ( { name : 'skip' , inputType : { type : 'Int' , kind : 'scalar' , isRequired : false , isList : false , isNullable : false , } , } ) , cursor : ( typeName ) => ( { name : 'cursor' , inputType : { type : `${ typeName }WhereUniqueInput` , kind : 'object' , isRequired : false , isList : false , isNullable : false , } , } ) , } ; export const prismaStrategy = { paginationArgNames : keys ( prismaPaginationArgsToDmmfArgs ) , transformDmmfArgs ( { paginationArgNames , args , field } ) { const fieldOutputTypeName = DMMFHelpers . getTypeName ( field . outputType . type ) ; args = args . filter ( ( dmmfArg ) => ! paginationArgNames . includes ( dmmfArg . name ) ) ; args . push ( prismaPaginationArgsToDmmfArgs . take ( fieldOutputTypeName ) , prismaPaginationArgsToDmmfArgs . skip ( fieldOutputTypeName ) , prismaPaginationArgsToDmmfArgs . cursor ( fieldOutputTypeName ) ) ; return args ; } , resolve ( args ) { return args ; } , } ;