Skip to content
Open
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
39 changes: 18 additions & 21 deletions package/src/GraphEntityGenTemplates.bs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 13 additions & 11 deletions package/src/GraphEntityGenTemplates.res
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
open Types

let loadNewEntityId = (~name) =>
` let loaded${name} = new ${name}(entityId);
`
Expand All @@ -17,23 +19,23 @@ let setFieldNameToFieldType = (~fieldName, ~fieldType) =>
` ${fieldName}: ${fieldType};
`

let getDefaultValues = typeString =>
switch typeString {
| "Bytes" => `Bytes.fromHexString("0x00") as Bytes` // needs to be even length for some reason
| "Address" => `Address.fromString("0x0000000000000000000000000000000000000000")`
| "Int" => "0"
| "String" => `""`
| "BigInt" => "BigInt.zero()"
| "BigDecimal" => "BigDecimal.zero()"
| "Boolean" => "false"
| unknownType => `"${unknownType} - Unknown type"`
let getDefaultValues = (graphType: GraphSchema.graphSchemaDataTypes) =>
switch graphType {
| #Bytes => `Bytes.fromHexString("0x00") as Bytes` // needs to be even length for some reason
| #Address => `Address.fromString("0x0000000000000000000000000000000000000000")`
| #Int => "0"
| #String => `""`
| #BigInt => "BigInt.zero()"
| #BigDecimal => "BigDecimal.zero()"
| #Boolean => "false"
// | unknownType => `"${unknownType->Obj.magic} - Unknown type"`
}

let toStringConverter = (paramName, paramType) =>
switch paramType {
| "Bytes" => `${paramName}.toHex()`
| "Address" => `${paramName}.toHex()`
| "Int"
| "i32"
| "BigInt" =>
`${paramName}.toString()`
| "BigDecimal" => `${paramName}.toString()`
Expand Down
101 changes: 48 additions & 53 deletions package/src/Index.bs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading