Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion src/dataconnect/graphqlError.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,31 @@
import { GraphqlError } from "./types";
import * as Table from "cli-table3";

export function prettify(err: GraphqlError): string {

Check warning on line 4 in src/dataconnect/graphqlError.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Missing JSDoc comment
const message = err.message;
let message = err.message;
let header = err.extensions?.file ?? "";
if (err.locations && err.locations.length) {
const line = err.locations[0]?.line ?? "";
if (line) {
header += `:${line}`;
}
}

if (err.path && err.path.length) {
let pathStr = "On ";
for (let i = 0; i < err.path.length; i++) {
if (typeof err.path[i] === "string") {
if (i === 0) {
pathStr += err.path[i];
} else {
pathStr = `${pathStr}.${err.path[i]}`;
}
} else {
pathStr = `${pathStr}[${err.path[i]}]`;
}
}
message = `${pathStr}: ${message}`;
}
return header.length ? `${header}: ${message}` : message;
}

Expand All @@ -21,7 +37,7 @@
return ["", err.message];
}

export function prettifyTable(errs: GraphqlError[]): string {

Check warning on line 40 in src/dataconnect/graphqlError.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Missing JSDoc comment
const table = new Table({
head: ["Type", "Issue", "Workaround", "Reason"],
style: { head: ["yellow"] },
Expand Down
1 change: 1 addition & 0 deletions src/dataconnect/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@

export interface GraphqlError {
message: string;
path?: (string | number)[];
locations?: {
line: number;
column: number;
Expand All @@ -89,7 +90,7 @@
file?: string;
warningLevel?: WarningLevel;
workarounds?: Workaround[];
[key: string]: any;

Check warning on line 93 in src/dataconnect/types.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
};
}
export interface BuildResult {
Expand All @@ -105,7 +106,7 @@
};
}

export function requiresVector(dm?: DeploymentMetadata): boolean {

Check warning on line 109 in src/dataconnect/types.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Missing JSDoc comment
return dm?.primaryDataSource?.postgres?.requiredExtensions?.includes("vector") ?? false;
}

Expand Down Expand Up @@ -193,7 +194,7 @@
connectorYaml: ConnectorYaml;
}

export function toDatasource(

Check warning on line 197 in src/dataconnect/types.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Missing JSDoc comment
projectId: string,
locationId: string,
ds: DatasourceYaml,
Expand Down Expand Up @@ -222,16 +223,16 @@
}

export interface ExecuteGraphqlResponse {
data: Record<string, any>;

Check warning on line 226 in src/dataconnect/types.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
errors: any[];

Check warning on line 227 in src/dataconnect/types.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
}

export interface ExecuteGraphqlResponseError {
error: { code: number; message: string; status: string; details: any[] };

Check warning on line 231 in src/dataconnect/types.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
}

interface ImpersonationAuthenticated {
authClaims: any;

Check warning on line 235 in src/dataconnect/types.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
}
interface ImpersonationUnauthenticated {
unauthenticated: boolean;
Expand Down
Loading