Skip to content

Commit

Permalink
refactor: include immutable detection at parse level
Browse files Browse the repository at this point in the history
  • Loading branch information
JulissaDantes committed Jul 25, 2024
1 parent 9074c6f commit 03198e9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ jobs:
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install Python dependencies
run: sudo apt-get install python3-distutils
- name: Install dependencies and build
run: pnpm install --frozen-lockfile
Expand Down
10 changes: 5 additions & 5 deletions packages/devtools/src/schema/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,10 +288,7 @@ export class SchemaParser {
immutableFields: Array.from(
new Set(
Object.keys(object.properties)
.filter((key) => {
const property = object.properties[key];
return property.immutable === true || ('item' in property && property.item && property.item.immutable)
})
.filter((key) => object.properties[key].immutable === true)
.concat(inheritedImmutableFields),
),
),
Expand Down Expand Up @@ -328,7 +325,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 @@ -347,6 +344,7 @@ export class SchemaParser {
key,
innerType,
required,
immutable,
directives,
hasCreateModel,
)
Expand Down Expand Up @@ -520,6 +518,7 @@ export class SchemaParser {
fieldName: string,
type: GraphQLList<GraphQLType>,
required: boolean,
immutable: boolean,
directives: Array<DirectiveAnnotation>,
hasCreateModel: boolean,
): DefinitionWithReferences<ListFieldDefinition> {
Expand All @@ -537,6 +536,7 @@ export class SchemaParser {
const definition: ListFieldDefinition = {
type: 'list',
required,
immutable,
item: item.definition,
maxLength: list.args.maxLength as number,
}
Expand Down
3 changes: 0 additions & 3 deletions packages/runtime/test/__snapshots__/runtime.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,6 @@ type Favorite implements Node {
tag: String!
note: String
docID: CeramicStreamID!
extra: String
doc: Node
}
Expand Down Expand Up @@ -454,7 +453,6 @@ input FavoriteInput {
tag: String!
note: String
docID: CeramicStreamID!
extra: String
}
input SetOptionsInput {
Expand Down Expand Up @@ -1810,7 +1808,6 @@ scalar CeramicCommitID @specifiedBy(url: "https://cips.ceramic.network/CIPs/cip-
input PartialPostInput {
date: DateTime
text: String
testList: [String]
}
type EnableIndexingPostPayload {
Expand Down

0 comments on commit 03198e9

Please sign in to comment.