How to Query an Interface?


(Powers Rc) #1

I have developed an interface which several node types are implemented with using the same syntax found here. I can not however figure out how to query that defined interface, or if that is even possible.

Using the example found in the linked document above. How would I query the "Person" interface?
When I try and query my interface I get an empty list inside of my object.

Thanks


(William Lyon) #2

Could you share the query you have so far?

If you have an Actor type that implements the Person interface, then you'll want to use an Inline Fragment in the query. For example, from that sample schema getting actors for a movie would look something like:

{
  Movie {
    actors {
        ... on Actor {
          name
        }
    }
  }
}

(Powers Rc) #3

I was trying something like below.

{
  Person{
    name
    born
  }
}

I was thinking that the interface was the parent of the node type that implements it. So you have to access the specific node type before referring to the interface? Is it possible to just query all the node types of a specific interface, like the example above?

Could you also explain the difference between "Implements" & "Extends"? I tried to use "extends" in-place of "implements" but Neo4j reject the idl.


(Powers Rc) #4

Is there a way to query all nodes and relationships using graphQL?