Remove hard-coded record types #52

Merged
ashwin merged 11 commits from deep-stack/laconic-sdk:ng-rm-record-types into main 2024-01-15 04:58:56 +00:00
2 changed files with 21 additions and 3 deletions
Showing only changes of commit e92bf8e431 - Show all commits

View File

@ -16,7 +16,16 @@ const attributeField = `
... on StringValue { string: value }
... on BytesValue { bytes: value }
... on LinkValue { link: value }
... on ArrayValue { array: value { __typename } }
... on ArrayValue {
array: value {
... on BooleanValue { bool: value }
... on IntValue { int: value }
... on FloatValue { float: value }
... on StringValue { string: value }
... on BytesValue { bytes: value }
... on LinkValue { link: value }
}
}
... on MapValue { map: value { key mapping: value { __typename } } }
}
}

View File

@ -86,10 +86,19 @@ export class Util {
}
static fromGQLValue(obj: any) {
// Get first non-null key
const present = Object.keys(obj).find(k => obj[k] !== null);
if (present === undefined) {
throw new Error('Object has no non-null values');
}
// Create an array if array type attribute
if (present === 'array') {
return obj[present].map((e: any) => {
return this.fromGQLValue(e);
});
}
return obj[present];
}