Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Continuation of derivedField fix - initial move to using non-polymorphic types #90

Open
wants to merge 1 commit into
base: jasoons/derived-fields
Choose a base branch
from
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