|
7 | 7 | type RelationsParam, |
8 | 8 | } from '@graphprotocol/grc-20'; |
9 | 9 | import type { Entity } from '@graphprotocol/hypergraph'; |
10 | | -import { store, Type } from '@graphprotocol/hypergraph'; |
| 10 | +import { store, TypeUtils } from '@graphprotocol/hypergraph'; |
11 | 11 | import request, { gql } from 'graphql-request'; |
12 | 12 |
|
13 | 13 | export type PreparePublishParams<S extends Entity.AnyNoContext> = { |
@@ -67,15 +67,16 @@ export const preparePublish = async <S extends Entity.AnyNoContext>({ |
67 | 67 | const fields = entity.__schema.fields; |
68 | 68 |
|
69 | 69 | if (data?.entity === null) { |
| 70 | + // TODO |
70 | 71 | for (const [key, propertyId] of Object.entries(mappingEntry.properties || {})) { |
71 | 72 | let serializedValue: string = entity[key]; |
72 | | - if (fields[key] === Type.Checkbox) { |
| 73 | + if (TypeUtils.isCheckboxOrOptionalCheckboxType(fields[key])) { |
73 | 74 | serializedValue = Graph.serializeCheckbox(entity[key]); |
74 | | - } else if (fields[key] === Type.Date) { |
| 75 | + } else if (TypeUtils.isDateOrOptionalDateType(fields[key])) { |
75 | 76 | serializedValue = Graph.serializeDate(entity[key]); |
76 | | - } else if (fields[key] === Type.Point) { |
| 77 | + } else if (TypeUtils.isPointOrOptionalPointType(fields[key])) { |
77 | 78 | serializedValue = Graph.serializePoint(entity[key]); |
78 | | - } else if (fields[key] === Type.Number) { |
| 79 | + } else if (TypeUtils.isNumberOrOptionalNumberType(fields[key])) { |
79 | 80 | serializedValue = Graph.serializeNumber(entity[key]); |
80 | 81 | } |
81 | 82 | values.push({ property: propertyId, value: serializedValue }); |
@@ -105,14 +106,15 @@ export const preparePublish = async <S extends Entity.AnyNoContext>({ |
105 | 106 |
|
106 | 107 | if (data?.entity) { |
107 | 108 | for (const [key, propertyId] of Object.entries(mappingEntry.properties || {})) { |
| 109 | + // TODO |
108 | 110 | let serializedValue: string = entity[key]; |
109 | | - if (fields[key] === Type.Checkbox) { |
| 111 | + if (TypeUtils.isCheckboxOrOptionalCheckboxType(fields[key])) { |
110 | 112 | serializedValue = Graph.serializeCheckbox(entity[key]); |
111 | | - } else if (fields[key] === Type.Date) { |
| 113 | + } else if (TypeUtils.isDateOrOptionalDateType(fields[key])) { |
112 | 114 | serializedValue = Graph.serializeDate(entity[key]); |
113 | | - } else if (fields[key] === Type.Point) { |
| 115 | + } else if (TypeUtils.isPointOrOptionalPointType(fields[key])) { |
114 | 116 | serializedValue = Graph.serializePoint(entity[key]); |
115 | | - } else if (fields[key] === Type.Number) { |
| 117 | + } else if (TypeUtils.isNumberOrOptionalNumberType(fields[key])) { |
116 | 118 | serializedValue = Graph.serializeNumber(entity[key]); |
117 | 119 | } |
118 | 120 |
|
|
0 commit comments