From f388abacc1f91995faf3681a4d038c62ee261f66 Mon Sep 17 00:00:00 2001 From: Ryan Goetz Date: Wed, 28 Feb 2024 13:05:14 -1000 Subject: [PATCH] Allow for the passing of 'null' value Establishing a default behavior to gracefully handle schemas with null values. Instead of encountering server-side errors that disrupt sequence expansion, null values will now be implicitly passed through. This decision places the onus on the expansion logic to implement appropriate null checks and handle potential null cases accordingly. --- .../batchLoaders/simulatedActivityBatchLoader.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/sequencing-server/src/lib/batchLoaders/simulatedActivityBatchLoader.ts b/sequencing-server/src/lib/batchLoaders/simulatedActivityBatchLoader.ts index e5915ec8ec..074b7258d5 100644 --- a/sequencing-server/src/lib/batchLoaders/simulatedActivityBatchLoader.ts +++ b/sequencing-server/src/lib/batchLoaders/simulatedActivityBatchLoader.ts @@ -231,6 +231,9 @@ export function mapGraphQLActivityInstance( function convertType(value: any, schema: Schema): any { switch (schema.type) { case SchemaTypes.Int: + if (value === null) { + return value; + } if (value > Number.MAX_SAFE_INTEGER || value < Number.MIN_SAFE_INTEGER) { return value.toString(); } @@ -238,7 +241,10 @@ function convertType(value: any, schema: Schema): any { case SchemaTypes.Real: return value; case SchemaTypes.Duration: - return Temporal.Duration.from(parse(value).toISOString()); + if (value !== null) { + return Temporal.Duration.from(parse(value).toISOString()); + } + return value; case SchemaTypes.Boolean: return value; case SchemaTypes.Path: @@ -246,15 +252,21 @@ function convertType(value: any, schema: Schema): any { case SchemaTypes.String: return value; case SchemaTypes.Series: + if (value === null) { + return value; + } return value.map((value: any) => convertType(value, schema.items)); case SchemaTypes.Struct: + if (value === null) { + return value; + } const struct: { [attributeName: string]: any } = {}; for (const [attributeKey, attributeSchema] of Object.entries(schema.items)) { struct[attributeKey] = convertType(value[attributeKey], attributeSchema); } return struct; case SchemaTypes.Variant: - if (schema.variants.length === 1 && schema.variants[0]?.key === 'VOID') { + if (value === null || (schema.variants.length === 1 && schema.variants[0]?.key === 'VOID')) { return null; } return value;