Writing a GraphQL model that programmatically retrieves relevant Neo4j constraints

25 views Asked by At

I am a seasoned Neo4j user who is new to GraphQL. I have inherited a codebase that explicitly models all Neo4j nodes and relationships as GraphQL objects.

I would like to allow GraphQL users to determine what uniqueness constraints, if any, affect any given object.

For an individual object, I believe I can deliver this by doing something like:

type Resource {
    id: BigInt!
    name: String
    category: String
    lastModified: DateTime
    constraints: [String!]! @cypher(statement: "SHOW UNIQUENESS CONSTRAINTS YIELD * WHERE labelsOrTypes=[\"Resource\\"] RETURN properties;")
}

This does not seem efficient, however, and it would be a very redundant hard-coded solution when I have dozens of objects whose type literally represents the label of the given node.

What is the appropriate solution here?

0

There are 0 answers