From 9dfaa51badb3f134d0e6d35b09d07e68be8ff3ee Mon Sep 17 00:00:00 2001 From: omreego Date: Tue, 9 Jan 2024 09:41:53 -0800 Subject: [PATCH] no error tests --- package-lock.json | 20 -------------------- src/adapter/index.ts | 6 ++++-- src/errors.ts | 2 +- 3 files changed, 5 insertions(+), 23 deletions(-) diff --git a/package-lock.json b/package-lock.json index e185eca..ee28fb8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -32,7 +32,6 @@ "@types/lodash": "^4.14.194", "@types/luxon": "^3.1.0", "@types/node": "^16.11.41", - "@types/pino": "^7.0.5", "@types/pluralize": "^0.0.29", "@types/tmp": "^0.2.0", "@types/toposort": "^2.0.3", @@ -1395,16 +1394,6 @@ "integrity": "sha512-jh6m0QUhIRcZpNv7Z/rpN+ZWXOicUUQbSoWks7Htkbb9IjFQj4kzcX/xFCkjstCj5flMsN8FiSvt+q+Tcs4Llg==", "dev": true }, - "node_modules/@types/pino": { - "version": "7.0.5", - "resolved": "https://registry.npmjs.org/@types/pino/-/pino-7.0.5.tgz", - "integrity": "sha512-wKoab31pknvILkxAF8ss+v9iNyhw5Iu/0jLtRkUD74cNfOOLJNnqfFKAv0r7wVaTQxRZtWrMpGfShwwBjOcgcg==", - "deprecated": "This is a stub types definition. pino provides its own type definitions, so you do not need this installed.", - "dev": true, - "dependencies": { - "pino": "*" - } - }, "node_modules/@types/pluralize": { "version": "0.0.29", "resolved": "https://registry.npmjs.org/@types/pluralize/-/pluralize-0.0.29.tgz", @@ -6882,15 +6871,6 @@ "integrity": "sha512-jh6m0QUhIRcZpNv7Z/rpN+ZWXOicUUQbSoWks7Htkbb9IjFQj4kzcX/xFCkjstCj5flMsN8FiSvt+q+Tcs4Llg==", "dev": true }, - "@types/pino": { - "version": "7.0.5", - "resolved": "https://registry.npmjs.org/@types/pino/-/pino-7.0.5.tgz", - "integrity": "sha512-wKoab31pknvILkxAF8ss+v9iNyhw5Iu/0jLtRkUD74cNfOOLJNnqfFKAv0r7wVaTQxRZtWrMpGfShwwBjOcgcg==", - "dev": true, - "requires": { - "pino": "*" - } - }, "@types/pluralize": { "version": "0.0.29", "resolved": "https://registry.npmjs.org/@types/pluralize/-/pluralize-0.0.29.tgz", diff --git a/src/adapter/index.ts b/src/adapter/index.ts index 6127b1f..fb8850a 100644 --- a/src/adapter/index.ts +++ b/src/adapter/index.ts @@ -1,4 +1,5 @@ import * as gql from 'graphql'; +import {Maybe} from 'graphql/jsutils/Maybe'; import _ from 'lodash'; import {DateTime} from 'luxon'; import {singular} from 'pluralize'; @@ -305,7 +306,8 @@ export function asV2AST(ast: gql.ASTNode, typeInfo: gql.TypeInfo): gql.ASTNode { export class QueryAdapter { constructor( private readonly faros: FarosClient, - private readonly v1Schema: gql.GraphQLSchema + private readonly v1Schema: gql.GraphQLSchema, + private readonly v2Schema: Maybe = undefined ) { if (faros.graphVersion !== 'v2') { throw new VError( @@ -427,7 +429,7 @@ export class QueryAdapter { const v1TypeInfo = new gql.TypeInfo(this.v1Schema); const nodePaths = this.nodePaths(v1AST, v1TypeInfo); let v2Query: string; - if (validationErrors.length > 0) { + if (this.v2Schema && validationErrors.length > 0) { const v2ValidationErrors = gql.validate(this.v2Schema, v1AST); if (v2ValidationErrors.length > 0) { throw new VError( diff --git a/src/errors.ts b/src/errors.ts index 3cfc033..a7761bf 100644 --- a/src/errors.ts +++ b/src/errors.ts @@ -46,7 +46,7 @@ export function wrapApiError(maybeError: Error, message?: string): Error { } const prefix = message ? `${message}: ` : ''; - const res: AxiosResponse | undefined = error.response; + const res: AxiosResponse | undefined = error.response; const info = { req: error.config || error.request