mirror of
https://github.com/cerc-io/watcher-ts
synced 2024-11-19 20:36:19 +00:00
Avoid setting null entity properties while fetching in store get API (#75)
This commit is contained in:
parent
3b835e81f8
commit
4c422e3ea2
@ -383,13 +383,19 @@ export const getSubgraphConfig = async (subgraphPath: string): Promise<any> => {
|
||||
|
||||
export const toEntityValue = async (instanceExports: any, entityInstance: any, data: any, field: ColumnMetadata, type: string) => {
|
||||
const { __newString, Value } = instanceExports;
|
||||
const { isArray, propertyName } = field;
|
||||
const { isArray, propertyName, isNullable } = field;
|
||||
|
||||
const entityKey = await __newString(propertyName);
|
||||
const entityValuePtr = await entityInstance.get(entityKey);
|
||||
const subgraphValue = Value.wrap(entityValuePtr);
|
||||
const value = data[propertyName];
|
||||
|
||||
// Check if the entity property is nullable.
|
||||
// No need to set the property if the value is null as well.
|
||||
if (isNullable && value === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
const entityValue = await formatEntityValue(instanceExports, subgraphValue, type, value, isArray);
|
||||
|
||||
return entityInstance.set(entityKey, entityValue);
|
||||
|
Loading…
Reference in New Issue
Block a user