11import type { Resolver , ObjectTypeComposer } from 'graphql-compose' ;
22import type { Model , Document } from 'mongoose' ;
33import type { ExtendedResolveParams , GenResolverOpts } from './index' ;
4- import { getOrCreateErrorPayload } from '../utils/getOrCreateErrorPayload ' ;
4+ import { getOrCreateErrorInterface } from '../utils/getOrCreateErrorInterface ' ;
55import { skipHelperArgs , recordHelperArgs , filterHelperArgs , sortHelperArgs } from './helpers' ;
66import findOne from './findOne' ;
77
@@ -21,7 +21,7 @@ export default function updateOne<TSource = Document, TContext = any>(
2121
2222 const findOneResolver = findOne ( model , tc , opts ) ;
2323
24- getOrCreateErrorPayload ( tc ) ;
24+ getOrCreateErrorInterface ( tc ) ;
2525
2626 const outputTypeName = `UpdateOne${ tc . getTypeName ( ) } Payload` ;
2727 const outputType = tc . schemaComposer . getOrCreateOTC ( outputTypeName , ( t ) => {
@@ -35,8 +35,8 @@ export default function updateOne<TSource = Document, TContext = any>(
3535 description : 'Updated document' ,
3636 } ,
3737 errors : {
38- type : '[ErrorPayload ]' ,
39- description : 'Errors that may occur, typically validations ' ,
38+ type : '[ErrorInterface ]' ,
39+ description : 'Errors that may occur' ,
4040 } ,
4141 } ) ;
4242 } ) ;
@@ -99,14 +99,14 @@ export default function updateOne<TSource = Document, TContext = any>(
9999 const validationErrors = doc . validateSync ( ) ;
100100 let errors : {
101101 path : string ;
102- messages : string [ ] ;
102+ message : string ;
103103 } [ ] ;
104104 if ( validationErrors && validationErrors . errors ) {
105105 errors = [ ] ;
106106 Object . keys ( validationErrors . errors ) . forEach ( ( key ) => {
107107 errors . push ( {
108108 path : key ,
109- messages : [ validationErrors . errors [ key ] . properties . message ] ,
109+ message : validationErrors . errors [ key ] . properties . message ,
110110 } ) ;
111111 } ) ;
112112 return {
0 commit comments