Skip to content

Fix for relationship mutations are not using the correct direction #107

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

Andy2003
Copy link
Collaborator

@Andy2003 Andy2003 commented Aug 7, 2020

This bugfix solves the problem that the mapping was wrong for incoming relations

(resolves #98)

…esolves neo4j-graphql#98)

This bugfix solves the problem that the mapping was wrong for incoming relations
@Andy2003 Andy2003 requested a review from jexp August 7, 2020 12:23
?.getDirective(DirectiveConstants.RELATION)?.let { it to false }
?.getDirective(DirectiveConstants.RELATION)?.let {
// do inverse mapping, if the current type is the `to` mapping of the relation
it to (fieldObjectType.getFieldDefinition(it.getArgument(RELATION_TO, null))?.name == typeName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to be careful, this doesn't always work. if you have a rich relationship which has the same type in to/from then we need to use the explicit information from that type.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need the information the rel-field then I mean that indicates the correct direction otherwise it's "random" if from/to is matching the type name.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see: #45

@@ -49,9 +49,13 @@ fun GraphQLFieldsContainer.relationshipFor(name: String): RelationshipInfo? {
?: throw IllegalArgumentException("$name is not defined on ${this.name}")
val fieldObjectType = field.type.inner() as? GraphQLFieldsContainer ?: return null

val (relDirective, isRelFromType) = if (isRelationType()) {
val (relDirective, inverse) = if (isRelationType()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps we can simplify this code a bit so it gets easier to understand.


val inverse = isRelFromType && fieldObjectType.getFieldDefinition(relInfo.startField)?.name != this.name
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where is this bit handled now?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was the fix for issue #45

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jexp jexp merged commit f8e26b3 into neo4j-graphql:master Aug 7, 2020
@@ -0,0 +1,323 @@
:toc:

= Movie Test TCK

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be Relationship Test TCK rather than Movie Test TCK?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for spotting this, fixed in master.

@Andy2003 Andy2003 deleted the bugfix/#98-fix-relationship-mapping branch August 27, 2020 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Relationship mutations are not using the correct direction
3 participants