({
errors,
variables,
additionalInfo,
service,
}: {
errors?: ReadonlyArray<GraphQLError>
variables: any
additionalInfo?: { executedMutationNames?: string[] }
service?: string
})
| 35 | } |
| 36 | |
| 37 | function processErrorArrayIfExists({ |
| 38 | errors, |
| 39 | variables, |
| 40 | additionalInfo, |
| 41 | service, |
| 42 | }: { |
| 43 | errors?: ReadonlyArray<GraphQLError> |
| 44 | variables: any |
| 45 | additionalInfo?: { executedMutationNames?: string[] } |
| 46 | service?: string |
| 47 | }): void { |
| 48 | let result = scanResult.pass |
| 49 | if (errors) { |
| 50 | result = scanResult.fail |
| 51 | errors.forEach((err: GraphQLError) => { |
| 52 | const { path, locations, message, extensions = {} } = err |
| 53 | printErrorMessage(message, additionalInfo) |
| 54 | // Sometimes dgraph can provide extra information about an error |
| 55 | extensions.code && |
| 56 | logger.debug(`Additional error info: ${extensions.code}`) |
| 57 | // Happens when data to load into Dgraph fails to pass the schema validation |
| 58 | path && logger.debug(`Additional path info: ${JSON.stringify(path)}`) |
| 59 | if (path?.[0] && path?.[1] && path?.[2]) { |
| 60 | if (path[0] === 'variable') { |
| 61 | if (path[1] === 'input') { |
| 62 | if (typeof path[2] === 'number') { |
| 63 | logger.debug(variables[path[1]][path[2]][path[3]]) |
| 64 | } |
| 65 | } |
| 66 | } |
| 67 | } |
| 68 | // Errors that can be schema format/syntax errors |
| 69 | locations && |
| 70 | logger.debug( |
| 71 | `Additional location info: ${JSON.stringify(locations, null, 2)}` |
| 72 | ) |
| 73 | }) |
| 74 | } |
| 75 | if (service) { |
| 76 | scanReport.pushData({ service, result, type: scanDataType.status }) |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | export function processGQLExecutionResult({ |
| 81 | errors: resErrors, |
no test coverage detected