@@ -42,9 +42,11 @@ export class Apollo implements Integration {
4242 /**
4343 * Iterate over resolvers of the ApolloServer instance before schemas are constructed.
4444 */
45- fill ( pkg . ApolloServerBase . prototype , 'constructSchema' , function ( orig : ( ) => void ) {
45+ fill ( pkg . ApolloServerBase . prototype , 'constructSchema' , function ( orig : ( ) => unknown ) {
4646 return function ( this : { config : { resolvers : ApolloModelResolvers [ ] } } ) {
47- this . config . resolvers = this . config . resolvers . map ( model => {
47+ const resolvers = Array . isArray ( this . config . resolvers ) ? this . config . resolvers : [ this . config . resolvers ] ;
48+
49+ this . config . resolvers = resolvers . map ( model => {
4850 Object . keys ( model ) . forEach ( resolverGroupName => {
4951 Object . keys ( model [ resolverGroupName ] ) . forEach ( resolverName => {
5052 if ( typeof model [ resolverGroupName ] [ resolverName ] !== 'function' ) {
@@ -79,23 +81,20 @@ function wrapResolver(
7981 const parentSpan = scope ?. getSpan ( ) ;
8082 const span = parentSpan ?. startChild ( {
8183 description : `${ resolverGroupName } .${ resolverName } ` ,
82- op : 'apollo' ,
84+ op : 'db.graphql. apollo' ,
8385 } ) ;
8486
85- scope ?. setSpan ( span ) ;
86-
8787 const rv = orig . call ( this , ...args ) ;
8888
8989 if ( isThenable ( rv ) ) {
90- return ( rv as Promise < unknown > ) . then ( ( res : unknown ) => {
90+ return rv . then ( ( res : unknown ) => {
9191 span ?. finish ( ) ;
92- scope ?. setSpan ( parentSpan ) ;
9392 return res ;
9493 } ) ;
9594 }
9695
9796 span ?. finish ( ) ;
98- scope ?. setSpan ( parentSpan ) ;
97+
9998 return rv ;
10099 } ;
101100 } ) ;
0 commit comments