Skip to content

Commit

Permalink
fix(graphql-transformer-migrator): fixed belongs to type relationshio…
Browse files Browse the repository at this point in the history
… check (#9003)
  • Loading branch information
lazpavel authored Nov 21, 2021
1 parent 8ea9e9d commit 9ecb90c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ exports[`Schema migration tests for @auth relational auth migrates as expected 1
"type Post @model @auth(rules: [{allow: owner}]) {
id: ID!
title: String!
author: User @hasOne(fields: [\\"owner\\"])
author: User @belongsTo(fields: [\\"owner\\"])
owner: ID! @index(name: \\"byOwner\\", sortKeyFields: [\\"id\\"])
}
Expand All @@ -302,7 +302,7 @@ type ConnectionProtected @model(queries: null) @auth(rules: [{allow: owner}]) {
name: String
owner: String
topLevelID: ID! @index(name: \\"byTopLevel\\", sortKeyFields: [\\"id\\"])
topLevel: OpenTopLevel @hasOne(fields: [\\"topLevelID\\"])
topLevel: OpenTopLevel @belongsTo(fields: [\\"topLevelID\\"])
}
"
`;
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type Comment @model @auth(rules: [{allow: public}]) {
id: ID!
postID: ID! @index(name: \\"byPost\\", sortKeyFields: [\\"content\\"])
content: String!
post: Post @hasOne(fields: [\\"postID\\"])
post: Post @belongsTo(fields: [\\"postID\\"])
}
"
`;
Expand Down Expand Up @@ -85,8 +85,8 @@ type PostEditor @model(queries: null) @auth(rules: [{allow: public}]) {
id: ID!
postID: ID! @index(name: \\"byPost\\", sortKeyFields: [\\"editorID\\"])
editorID: ID! @index(name: \\"byEditor\\", sortKeyFields: [\\"postID\\"])
post: Post! @hasOne(fields: [\\"postID\\"])
editor: User! @hasOne(fields: [\\"editorID\\"])
post: Post! @belongsTo(fields: [\\"postID\\"])
editor: User! @belongsTo(fields: [\\"editorID\\"])
}
type User @model @auth(rules: [{allow: public}]) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export function migrateConnection(node: any, ast: any) {
}
} else {
const relatedType = getRelatedType(ast, getFieldType(connectionField));
const biDirectionalRelation = relatedType.fields.some((relatedField: any) => {
const biDirectionalRelation = relatedType.fields.find((relatedField: any) => {
if (getFieldType(relatedField) !== node.name.value) {
return false;
}
Expand All @@ -62,7 +62,7 @@ export function migrateConnection(node: any, ast: any) {
return false;
}

return relatedField?.directives?.some((relatedDirective: any) => {
return relatedField?.directives?.find((relatedDirective: any) => {
return validConnectionDirectiveNames.has(relatedDirective.name.value);
});
});
Expand Down

0 comments on commit 9ecb90c

Please sign in to comment.