cancel
Showing results for 
Search instead for 
Did you mean: 

Interface Support in Neo4J-GraphQL-js

jman
Node Link

Hey guys,

I've seen some conflicting comments in the neo4j-graphql-js GitHub repository as to whether interfaces are supported in the autogenerated resolvers generated from a schema SDL file. It looks like they may be supported as inline fragments based on some GitHub activity, but the grandstack docs say they're a future feature and the docs generated in Graphiql don't seem to show interface fields in objects implementing that interface. Anyone know to what extent they're supported and, if they are, could you perhaps walk me through a simple example of querying for all implementations of a given interface via GraphQl? Thanks!

1 REPLY 1

MuddyBootsCode
Graph Steward

Hello, jman. I've got some interfaces in my project that I've been working on for awhile and they do get their own auto generated mutations. Probably the easiest way to see how that works and what they are is to create an interface type in your schema and then make a few implementations then when you start your GraphQL play ground you can see the various mutations in your schema, in my project I have:

interface Alert {
    id: ID!
    title: String
    text: String
    date: String
    days: String
}

type LeaseAlert implements Alert @isAuthenticated{
    id: ID!
    title: String
    text: String
    date: String
    days: String
    lease: Lease @relation(name: "ALERT", direction: "OUT")
}

type LandAlert implements Alert @isAuthenticated{
    id: ID!
    title: String
    text: String
    date: String
    days: String
    tract: Tract @relation(name: "ALERT", direction: "OUT")

So that I can create and implement alerts. The auto generated mutations give me complete CRUD functionality including the ability to create and delete relationships between the alert and it's intended target. So I'd say that while the docs may be a bit misleading the support for them is there.