Skip to content

Commit

Permalink
fix: recursiveNestedPaths not merging existing fields when hoisting r…
Browse files Browse the repository at this point in the history
…ow/collapsible fields (#2769)
  • Loading branch information
JarrodMFlesch committed Jun 4, 2023
1 parent 7c03e55 commit 536d701
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/graphql/schema/recursivelyBuildNestedPaths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ const recursivelyBuildNestedPaths = (parentName: string, nestedFieldName2: strin
const nestedPaths = field.fields.reduce((nestedFields, nestedField) => {
if (!fieldIsPresentationalOnly(nestedField)) {
if (!fieldAffectsData(nestedField)) {
return recursivelyBuildNestedPaths(parentName, nestedFieldName, nestedField);
return [
...nestedFields,
...recursivelyBuildNestedPaths(parentName, nestedFieldName, nestedField),
];
}

const nestedPathName = fieldAffectsData(nestedField) ? `${nestedFieldName ? `${nestedFieldName}__` : ''}${nestedField.name}` : undefined;
Expand Down
4 changes: 4 additions & 0 deletions test/collections-graphql/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ export default buildConfig({
name: 'C1',
type: 'group',
fields: [
{
type: 'text',
name: 'C2Text',
},
{
type: 'row',
fields: [
Expand Down
65 changes: 65 additions & 0 deletions test/collections-graphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ type Post_B1 {
}

type Post_C1 {
C2Text: String
C2: Post_C1_C2
}

Expand Down Expand Up @@ -386,6 +387,7 @@ input Post_where {
relationMultiRelationToHasMany: Post_relationMultiRelationToHasMany_Relation
A1__A2: Post_A1__A2_operator
B1__B2: Post_B1__B2_operator
C1__C2Text: Post_C1__C2Text_operator
C1__C2__C3: Post_C1__C2__C3_operator
D1__D2__D3__D4: Post_D1__D2__D3__D4_operator
updatedAt: Post_updatedAt_operator
Expand Down Expand Up @@ -506,6 +508,17 @@ input Post_B1__B2_operator {
exists: Boolean
}

input Post_C1__C2Text_operator {
equals: String
not_equals: String
like: String
contains: String
in: [String]
not_in: [String]
all: [String]
exists: Boolean
}

input Post_C1__C2__C3_operator {
equals: String
not_equals: String
Expand Down Expand Up @@ -573,6 +586,7 @@ input Post_where_or {
relationMultiRelationToHasMany: Post_relationMultiRelationToHasMany_Relation
A1__A2: Post_A1__A2_operator
B1__B2: Post_B1__B2_operator
C1__C2Text: Post_C1__C2Text_operator
C1__C2__C3: Post_C1__C2__C3_operator
D1__D2__D3__D4: Post_D1__D2__D3__D4_operator
updatedAt: Post_updatedAt_operator
Expand All @@ -592,6 +606,7 @@ input Post_where_and {
relationMultiRelationToHasMany: Post_relationMultiRelationToHasMany_Relation
A1__A2: Post_A1__A2_operator
B1__B2: Post_B1__B2_operator
C1__C2Text: Post_C1__C2Text_operator
C1__C2__C3: Post_C1__C2__C3_operator
D1__D2__D3__D4: Post_D1__D2__D3__D4_operator
updatedAt: Post_updatedAt_operator
Expand Down Expand Up @@ -959,9 +974,33 @@ type PostsDocAccessFields_C1_Delete {
}

type PostsDocAccessFields_C1_Fields {
C2Text: PostsDocAccessFields_C1_C2Text
C2: PostsDocAccessFields_C1_C2
}

type PostsDocAccessFields_C1_C2Text {
create: PostsDocAccessFields_C1_C2Text_Create
read: PostsDocAccessFields_C1_C2Text_Read
update: PostsDocAccessFields_C1_C2Text_Update
delete: PostsDocAccessFields_C1_C2Text_Delete
}

type PostsDocAccessFields_C1_C2Text_Create {
permission: Boolean!
}

type PostsDocAccessFields_C1_C2Text_Read {
permission: Boolean!
}

type PostsDocAccessFields_C1_C2Text_Update {
permission: Boolean!
}

type PostsDocAccessFields_C1_C2Text_Delete {
permission: Boolean!
}

type PostsDocAccessFields_C1_C2 {
create: PostsDocAccessFields_C1_C2_Create
read: PostsDocAccessFields_C1_C2_Read
Expand Down Expand Up @@ -2247,9 +2286,33 @@ type PostsFields_C1_Delete {
}

type PostsFields_C1_Fields {
C2Text: PostsFields_C1_C2Text
C2: PostsFields_C1_C2
}

type PostsFields_C1_C2Text {
create: PostsFields_C1_C2Text_Create
read: PostsFields_C1_C2Text_Read
update: PostsFields_C1_C2Text_Update
delete: PostsFields_C1_C2Text_Delete
}

type PostsFields_C1_C2Text_Create {
permission: Boolean!
}

type PostsFields_C1_C2Text_Read {
permission: Boolean!
}

type PostsFields_C1_C2Text_Update {
permission: Boolean!
}

type PostsFields_C1_C2Text_Delete {
permission: Boolean!
}

type PostsFields_C1_C2 {
create: PostsFields_C1_C2_Create
read: PostsFields_C1_C2_Read
Expand Down Expand Up @@ -2897,6 +2960,7 @@ input mutationPost_B1Input {
}

input mutationPost_C1Input {
C2Text: String
C2: mutationPost_C1_C2Input
}

Expand Down Expand Up @@ -2963,6 +3027,7 @@ input mutationPostUpdate_B1Input {
}

input mutationPostUpdate_C1Input {
C2Text: String
C2: mutationPostUpdate_C1_C2Input
}

Expand Down

0 comments on commit 536d701

Please sign in to comment.