Problem with Type definition and query in "Introduction to Neo4j & GraphQL" - Lesson "GraphQL Relationships"

In the lesson " GraphQL Relationships" there are (at least I suppose so) errors both in "Type definition" and GraphQL query.
Here the code that works for me:
Type definition

type Movie {
	title: String!
	year: Int
	plot: String
	imdbRating: Float
	countries: [String]
	languages: [String]
	poster: String
	revenue: Int
	budget: Int
	actors: [Actor!]! @relationship(type: "ACTED_IN", direction: IN, properties: "ActedIn")
  genres: [Genre!]! @relationship(type: "IN_GENRE", direction: OUT)
}

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

type Actor {
	name: String
	actedInMovies: [Movie!]! @relationship(type: "ACTED_IN", direction: OUT, properties: "ActedIn")
}

type Genre {
	name: String!
	movies: [Movie!]! @relationship(type: "IN_GENRE", direction: IN)
}

type ActedIn @relationshipProperties {
	role: String
}

Query

query MyQuery {
  movies (where: {title: "Matrix, The"}) {
    title
    actors {
      name
    }    
    actorsConnection {
      edges {
        properties {
          role
        }
      }
    }
    genres {
      name
    }
  }
}
1 Like

Hi @Andrea!

Sorry that you've encountered issues here. We'll get this fixed as soon as possible.

Thanks for bringing this to our attention.

Best regards,

Michael

1 Like

Hi @Andrea ,

I was just wondering why this code causes error message on GraphQL Toolbox;

Directive "@relationshipProperties" may not be used on INTERFACE.

Thank you for raising this issue!

HI @michael.webb ,

After I change the "interface" to "type" as Andrea suggested, the error goes away,
but is it OK not to use interface here?

Can I understand that we do not have to use interface if we do not need to reuse the code (in this case "Rated"), as interface shines in the reusability?

Hi @yoshiro.fujimori!

Using type instead of interface is the correct action here. This was a major change in the library beginning at version 5.0.0.

Since it relates directly to the property of the relationship directive there should be no need for another type to implement it, which is why we changed it to a type.

As you say, interfaces should be used to structure implementing types. I recommend the interfaces and unions section on the GraphQL learn pages.

Best regards,

Michael