// Formats an error using the default GraphQL `formatError` function, and // custom formatting using some other options. const formatError = (error: GraphQLError) => { // Get the appropriate formatted error object, including any extended error // fields if the user wants them. const formattedError = extendedErrors && extendedErrors.length ? extendedFormatError(error, extendedErrors) : defaultFormatError(error); // If the user wants to see the error’s stack, let’s add it to the // formatted error. if (showErrorStack) (formattedError as Record<string, any>)['stack'] = error.stack != null && showErrorStack === 'json' ? error.stack.split('\n') : error.stack; return formattedError; }