|
1 | | -import { Plugin, OnResolverCalledHook, Path, isAsyncIterable, DefaultContext } from '@envelop/core'; |
| 1 | +import { Plugin, Path, isAsyncIterable, DefaultContext } from '@envelop/core'; |
| 2 | +// import { OnResolve, useOnResolve } from '@envelop/on-resolve'; |
2 | 3 | import { print, FieldNode, Kind, OperationDefinitionNode, ExecutionResult, GraphQLError } from 'graphql'; |
3 | 4 |
|
4 | 5 | enum AttributeName { |
@@ -125,56 +126,47 @@ export const useNewRelic = (rawOptions?: UseNewRelicOptions): Plugin => { |
125 | 126 |
|
126 | 127 | const operationSegment = instrumentationApi.getActiveSegment(); |
127 | 128 |
|
128 | | - const onResolverCalled: OnResolverCalledHook | undefined = options.trackResolvers |
129 | | - ? async ({ args: resolversArgs, info }) => { |
130 | | - const logger = await logger$; |
131 | | - const { returnType, path, parentType } = info; |
132 | | - const formattedPath = flattenPath(path, delimiter); |
133 | | - const currentSegment = instrumentationApi.getActiveSegment(); |
134 | | - |
135 | | - if (!currentSegment) { |
136 | | - logger.trace('No active segment found at resolver call. Not recording resolver (%s).', formattedPath); |
137 | | - return () => {}; |
138 | | - } |
139 | | - |
140 | | - const resolverSegment = instrumentationApi.createSegment( |
141 | | - `resolver${delimiter}${formattedPath}`, |
142 | | - null, |
143 | | - operationSegment |
144 | | - ); |
145 | | - |
146 | | - if (!resolverSegment) { |
147 | | - logger.trace('Resolver segment was not created (%s).', formattedPath); |
148 | | - return () => {}; |
149 | | - } |
150 | | - |
151 | | - resolverSegment.start(); |
152 | | - |
153 | | - resolverSegment.addAttribute(AttributeName.RESOLVER_FIELD_PATH, formattedPath); |
154 | | - resolverSegment.addAttribute(AttributeName.RESOLVER_TYPE_NAME, parentType.toString()); |
155 | | - resolverSegment.addAttribute(AttributeName.RESOLVER_RESULT_TYPE, returnType.toString()); |
156 | | - |
157 | | - if (options.includeResolverArgs) { |
158 | | - const rawArgs = resolversArgs || {}; |
159 | | - const resolverArgsToTrack = options.isResolverArgsRegex |
160 | | - ? filterPropertiesByRegex(rawArgs, options.includeResolverArgs as RegExp) |
161 | | - : rawArgs; |
162 | | - |
163 | | - resolverSegment.addAttribute(AttributeName.RESOLVER_ARGS, JSON.stringify(resolverArgsToTrack)); |
164 | | - } |
165 | | - |
166 | | - return ({ result }) => { |
167 | | - if (options.includeRawResult) { |
168 | | - resolverSegment.addAttribute(AttributeName.RESOLVER_RESULT, JSON.stringify(result)); |
169 | | - } |
170 | | - |
171 | | - resolverSegment.end(); |
172 | | - }; |
173 | | - } |
174 | | - : undefined; |
| 129 | + if (options.trackResolvers) { |
| 130 | + // TODO: cant rewrap, figure out better approach |
| 131 | + // useOnResolve(args.schema, async ({ args: resolversArgs, info }) => { |
| 132 | + // const logger = await logger$; |
| 133 | + // const { returnType, path, parentType } = info; |
| 134 | + // const formattedPath = flattenPath(path, delimiter); |
| 135 | + // const currentSegment = instrumentationApi.getActiveSegment(); |
| 136 | + // if (!currentSegment) { |
| 137 | + // logger.trace('No active segment found at resolver call. Not recording resolver (%s).', formattedPath); |
| 138 | + // return () => {}; |
| 139 | + // } |
| 140 | + // const resolverSegment = instrumentationApi.createSegment( |
| 141 | + // `resolver${delimiter}${formattedPath}`, |
| 142 | + // null, |
| 143 | + // operationSegment |
| 144 | + // ); |
| 145 | + // if (!resolverSegment) { |
| 146 | + // logger.trace('Resolver segment was not created (%s).', formattedPath); |
| 147 | + // return () => {}; |
| 148 | + // } |
| 149 | + // resolverSegment.start(); |
| 150 | + // resolverSegment.addAttribute(AttributeName.RESOLVER_FIELD_PATH, formattedPath); |
| 151 | + // resolverSegment.addAttribute(AttributeName.RESOLVER_TYPE_NAME, parentType.toString()); |
| 152 | + // resolverSegment.addAttribute(AttributeName.RESOLVER_RESULT_TYPE, returnType.toString()); |
| 153 | + // if (options.includeResolverArgs) { |
| 154 | + // const rawArgs = resolversArgs || {}; |
| 155 | + // const resolverArgsToTrack = options.isResolverArgsRegex |
| 156 | + // ? filterPropertiesByRegex(rawArgs, options.includeResolverArgs as RegExp) |
| 157 | + // : rawArgs; |
| 158 | + // resolverSegment.addAttribute(AttributeName.RESOLVER_ARGS, JSON.stringify(resolverArgsToTrack)); |
| 159 | + // } |
| 160 | + // return ({ result }) => { |
| 161 | + // if (options.includeRawResult) { |
| 162 | + // resolverSegment.addAttribute(AttributeName.RESOLVER_RESULT, JSON.stringify(result)); |
| 163 | + // } |
| 164 | + // resolverSegment.end(); |
| 165 | + // }; |
| 166 | + // }); |
| 167 | + } |
175 | 168 |
|
176 | 169 | return { |
177 | | - onResolverCalled, |
178 | 170 | onExecuteDone({ result }) { |
179 | 171 | const sendResult = (singularResult: ExecutionResult) => { |
180 | 172 | if (singularResult.data && options.includeRawResult) { |
|
0 commit comments