Skip to content
This repository has been archived by the owner on Sep 3, 2021. It is now read-only.

Interfaced relations fix #374

Merged
merged 2 commits into from
Jan 9, 2020
Merged

Interfaced relations fix #374

merged 2 commits into from
Jan 9, 2020

Conversation

ChristiaanScheermeijer
Copy link
Contributor

Hi,

This is my first PR to this repository. The code is quite complex so I can't oversee all edge cases regarding these changes.

This PR will fix relation mutations with interfaced types. Given the following schema:

interface Person {
  userId: ID!
  name: String
}

type User implements Person {
  userId: ID!
  name: String
}

type Actor implements Person {
  userId: ID!
  name: String
  awards: Int
}

type Movie {
  movieId: ID!
  actors: [Actor] @relation(name: "ACTORS", direction: "OUT")
  seenBy: Person @relation(name: "SEEN_BY", direction: "OUT")
}

The following query will work:

mutation {
  AddMovieSeenBy(
    from: { movieId: "123" },
    to: { userId: "456" }
  ) {
    from {
      movieId
    }
    to {
      name
      ... on Actor {
        awards
      }
    }
  }
}

Happy to hear your feedback!

Fixed #182

@codecov-io
Copy link

codecov-io commented Jan 9, 2020

Codecov Report

Merging #374 into master will increase coverage by 0.24%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #374      +/-   ##
==========================================
+ Coverage    96.3%   96.55%   +0.24%     
==========================================
  Files          24       24              
  Lines        2844     2846       +2     
==========================================
+ Hits         2739     2748       +9     
+ Misses        105       98       -7
Impacted Files Coverage Δ
src/translate.js 98.68% <100%> (+0.36%) ⬆️
src/utils.js 94.51% <0%> (+0.95%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ea66d52...7bb40e7. Read the comment docs.

@@ -1,6 +1,6 @@
import { augmentTypeDefs, augmentSchema } from '../../src/index';
import { ApolloServer, gql, makeExecutableSchema } from 'apollo-server';
import { v1 as neo4j } from 'neo4j-driver';
import neo4j from 'neo4j-driver';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure if this should be in this pull request, but the example server didn't work for on the master branch.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is a result of upgrading the version of neo4j-driver, which removes the v1 namespace. I was lazy and only updated movies-middleware.js which is why this one was failing. My fault.

@johnymontana
Copy link
Contributor

Looks good. Thanks @ChristiaanScheermeijer!

@johnymontana johnymontana merged commit 3e16662 into neo4j-graphql:master Jan 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Question/Suggestion] Autogeneration of Mutations for relations to Interface types
3 participants