Skip to content

Commit

Permalink
feat: update _parseListType (#229)
Browse files Browse the repository at this point in the history
* feat: update _parseListType

* refactor: move directive check to parse method
  • Loading branch information
JulissaDantes authored Jul 26, 2024
1 parent 7b5e5c3 commit 941a947
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"cSpell.words": [
"undeployed"
]
}
2 changes: 2 additions & 0 deletions packages/devtools/src/schema/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@ export class SchemaParser {
hasCreateModel: boolean,
): DefinitionWithReferences<ListFieldDefinition> {
const list = directives.find((d) => d.name === 'list')
const immutable = directives.some((item) => item.name === 'immutable')
if (list == null) {
throw new Error(`Missing @list directive on list field ${fieldName} of object ${objectName}`)
}
Expand All @@ -534,6 +535,7 @@ export class SchemaParser {
const definition: ListFieldDefinition = {
type: 'list',
required,
immutable,
item: item.definition,
maxLength: list.args.maxLength as number,
}
Expand Down
3 changes: 2 additions & 1 deletion packages/devtools/test/schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,7 @@ describe('schema parsing and compilation', () => {
) {
uniqueValue: Int @immutable
tag: String! @string(minLength: 1, maxLength: 100)
uniqueListValue: [Int] @list(maxLength: 5) @immutable
}
`),
).toMatchObject({
Expand All @@ -803,7 +804,7 @@ describe('schema parsing and compilation', () => {
action: 'create',
model: {
name: 'ModelWithImmutableProp',
immutableFields: ['uniqueValue'],
immutableFields: ['uniqueValue', 'uniqueListValue'],
accountRelation: { type: 'single' },
description: 'Test model with an immutable int property',
schema: {
Expand Down

0 comments on commit 941a947

Please sign in to comment.