File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,8 +9,12 @@ export const getTypeFromValue = (
99 value ?: LiteralValue | null ,
1010 dataTypes ?: DataType [ ]
1111) : string => {
12+
13+
1214 // 1. Serialize value to a JSON string for embedding in source code.
13- const literal = JSON . stringify ( value ?. value ) ;
15+ const literal = JSON . stringify ( value ?. value , ( key , val ) =>
16+ typeof val === 'bigint' ? val . toString ( ) : val
17+ )
1418
1519 if ( ! literal ) return "any"
1620
Original file line number Diff line number Diff line change @@ -125,7 +125,12 @@ export function generateFlowSourceCode(
125125 } ) ;
126126 return `/* @pos ${ nodeId } ${ paramIdx } */ ${ refCode } ` ;
127127 }
128- if ( val . __typename === "LiteralValue" ) return `/* @pos ${ nodeId } ${ paramIdx } */ ${ JSON . stringify ( val . value ) } ` ;
128+ if ( val . __typename === "LiteralValue" ) {
129+ const jsonString = JSON . stringify ( val ?. value , ( key , val ) =>
130+ typeof val === 'bigint' ? val . toString ( ) : val
131+ )
132+ return `/* @pos ${ nodeId } ${ paramIdx } */ ${ jsonString } ` ;
133+ }
129134 if ( val . __typename === "NodeFunctionIdWrapper" ) {
130135 const wrapper = val as NodeFunctionIdWrapper ;
131136 return generateNodeCall ( wrapper . id ! , nodeId , paramIdx ) ;
@@ -172,7 +177,12 @@ export function generateFlowSourceCode(
172177 } ) ;
173178 return `/* @pos ${ nodeId } ${ index } */ ${ refCode } ` ;
174179 }
175- if ( val . __typename === "LiteralValue" ) return `/* @pos ${ nodeId } ${ index } */ ${ JSON . stringify ( val . value ) } ` ;
180+ if ( val . __typename === "LiteralValue" ) {
181+ const jsonString = JSON . stringify ( val ?. value , ( key , val ) =>
182+ typeof val === 'bigint' ? val . toString ( ) : val
183+ )
184+ return `/* @pos ${ nodeId } ${ index } */ ${ jsonString } ` ;
185+ }
176186 if ( val . __typename === "NodeFunctionIdWrapper" ) {
177187 const wrapper = val as NodeFunctionIdWrapper ;
178188
Original file line number Diff line number Diff line change @@ -2,17 +2,21 @@ import ts from "typescript";
22import { DataType , LiteralValue } from "@code0-tech/sagittarius-graphql-types" ;
33import { createCompilerHost , getSharedTypeDeclarations , ValidationResult } from "../utils" ;
44
5+
56export const getValueValidation = (
67 type ?: string ,
78 value ?: LiteralValue ,
89 dataTypes ?: DataType [ ]
910) : ValidationResult => {
10- const valueAsCode = JSON . stringify ( value ?. value ) ;
11+
12+ const jsonString = JSON . stringify ( value ?. value , ( key , val ) =>
13+ typeof val === 'bigint' ? val . toString ( ) : val
14+ )
1115
1216 // 1. Construct the source code for validation.
1317 const sourceCode = `
1418 ${ getSharedTypeDeclarations ( dataTypes ) }
15- const testValue: ${ type } = ${ valueAsCode } ;
19+ const testValue: ${ type } = ${ jsonString } ;
1620 ` ;
1721
1822 const fileName = "index.ts" ;
You can’t perform that action at this time.
0 commit comments