@@ -79,7 +79,7 @@ async function createSingle__(
7979) {
8080 return await withSpan (
8181 `create ${ list . graphql . names . outputTypeNameLower } ` ,
82- async ( ) => {
82+ async span => {
8383 // throw an accessDeniedError if not allowed
8484 await enforceListLevelAccessControl ( context , 'create' , list , inputData , undefined )
8585 await enforceFieldLevelAccessControl ( context , 'create' , list , inputData , undefined )
@@ -94,13 +94,17 @@ async function createSingle__(
9494 await beforeOperation ( )
9595
9696 // operation
97- const item = await context . prisma [ list . listKey ] . create ( {
97+ const result = await context . prisma [ list . listKey ] . create ( {
9898 data : list . isSingleton ? { ...data , id : 1 } : data ,
9999 } )
100100
101- return { item, afterOperation }
101+ span . setAttribute ( 'keystone.result.id' , result ?. id ?? '' )
102+ return { item : result , afterOperation }
102103 } ,
103- { 'keystone.list' : list . listKey , 'keystone.operation' : 'create' }
104+ {
105+ 'keystone.list' : list . listKey ,
106+ 'keystone.operation' : 'create' ,
107+ }
104108 )
105109}
106110
@@ -143,7 +147,7 @@ async function updateSingle__(
143147) {
144148 return await withSpan (
145149 `update ${ list . graphql . names . outputTypeNameLower } ` ,
146- async ( ) => {
150+ async span => {
147151 // validate and resolve the input filter
148152 const uniqueWhere = await resolveUniqueWhereInput ( where , list , context )
149153
@@ -164,15 +168,16 @@ async function updateSingle__(
164168 await beforeOperation ( )
165169
166170 // operation
167- const updatedItem = await context . prisma [ list . listKey ] . update ( {
171+ const result = await context . prisma [ list . listKey ] . update ( {
168172 where : { id : item . id } ,
169173 data,
170174 } )
175+ span . setAttribute ( 'keystone.result.id' , result ?. id ?? '' )
171176
172177 // after operation
173- await afterOperation ( updatedItem )
178+ await afterOperation ( result )
174179
175- return updatedItem
180+ return result
176181 } ,
177182 { 'keystone.list' : list . listKey , 'keystone.operation' : 'update' }
178183 )
@@ -186,7 +191,7 @@ async function deleteSingle__(
186191) {
187192 return await withSpan (
188193 `delete ${ list . graphql . names . outputTypeNameLower } ` ,
189- async ( ) => {
194+ async span => {
190195 // validate and resolve the input filter
191196 const uniqueWhere = await resolveUniqueWhereInput ( where , list , context )
192197
@@ -214,6 +219,7 @@ async function deleteSingle__(
214219
215220 // operation
216221 const result = await context . prisma [ list . listKey ] . delete ( { where : { id : item . id } } )
222+ span . setAttribute ( 'keystone.result.id' , result ?. id ?? '' )
217223
218224 // after operation
219225 await runSideEffectOnlyHook ( list , 'afterOperation' , {
@@ -236,7 +242,7 @@ async function actionSingle__(
236242) {
237243 return await withSpan (
238244 action . otel ,
239- async ( ) => {
245+ async span => {
240246 // no before operation hook for actions
241247
242248 // operation
@@ -248,6 +254,7 @@ async function actionSingle__(
248254 } ,
249255 context
250256 )
257+ span . setAttribute ( 'keystone.result.id' , ( result ?. id as string ) ?? '' )
251258
252259 // no after operation hook for actions
253260 return result
0 commit comments