Skip to content

Commit

Permalink
feat: update _parseListType
Browse files Browse the repository at this point in the history
  • Loading branch information
JulissaDantes committed Jul 26, 2024
1 parent 7b5e5c3 commit 56a1970
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions packages/devtools/src/schema/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ export class SchemaParser {
for (const [key, value] of Object.entries(objectFields)) {
const directives = getDirectives(this.#schema, value)

const immutable = directives.some((item) => item.name === 'immutable')
const [innerType, required] = isNonNullType(value.type)
? [value.type.ofType, true]
: [value.type, false]
Expand All @@ -344,6 +345,7 @@ export class SchemaParser {
key,
innerType,
required,
immutable,
directives,
hasCreateModel,
)
Expand Down Expand Up @@ -517,6 +519,7 @@ export class SchemaParser {
fieldName: string,
type: GraphQLList<GraphQLType>,
required: boolean,
immutable: boolean,
directives: Array<DirectiveAnnotation>,
hasCreateModel: boolean,
): DefinitionWithReferences<ListFieldDefinition> {
Expand All @@ -534,6 +537,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 56a1970

Please sign in to comment.