neo4j / graphql

A GraphQL to Cypher query execution layer for Neo4j and JavaScript GraphQL implementations.
https://neo4j.com/docs/graphql-manual/current/
Apache License 2.0
507 stars 149 forks source link

Add the ability to use the `@cypher` directive in relationship properties #1816

Open norbertBergmann opened 2 years ago

norbertBergmann commented 2 years ago

Describe the bug To make properties of a relationship accessible it is possible to modeled this relationship as specific relationship IntefaceType. In this scenario, the graphql query does not allowed querying the native database ID of this relationship.

Type definitions

type MaterialType {
  id: ID! @id
  materialType: String!
  specifiesContainers: [Container!]! @relationship(type: "hasProperty", properties: "Co_Mt_hasProperty", direction: IN)
}

type Container {
  id: ID! @id
  name: String
}

interface Co_Mt_hasProperty @relationshipProperties {
  value: String
  _id: ID! @cypher(statement: "RETURN ID(this)")
}

To Reproduce Steps to reproduce the behavior:

  1. Run the following Query...
    
    {
    materialTypes {
    specifiesContainersConnection {
      edges {
        value
        _id
      }
    }
    }
    }

2. It is not possible to query the _id  / native data base id of the edge
3. It is not possible to use directives to return the native data base id because the directive is ignored

**Expected behavior**
1. Should be possible to use directives for relationship properties
2. Should be possible to get access to the native data base id of a relationship automatically by the InterfaceTyp of the relationship

**System (please complete the following information):**

* OS: Ubuntu
* Version: [ @neo4j/graphql@3.1.0]
* Node.js version: [e.g. 16.16.0]
neo4j-team-graphql commented 2 years ago

Many thanks for raising this bug report @norbertBergmann. :bug: We will now attempt to reproduce the bug based on the steps you have provided.

Please ensure that you've provided the necessary information for a minimal reproduction, including but not limited to:

If you have a support agreement with Neo4j, please link this GitHub issue to a new or existing Zendesk ticket.

Thanks again! :pray:

darrellwarde commented 2 years ago

Hey @norbertBergmann, I've relabelled this as a feature request, because this is due to lack of support for the @cypher directive on relationship properties, and not that it is broken. Thanks!

josealvarez97 commented 1 year ago

Good day @darrellwarde,

Are there updates on this feature request? Alternatively, what would be the best workaround for this use case? I am having trouble finding a way to retrieve native database relationship IDs.

josealvarez97 commented 1 year ago

Did you find a workaround for your use case @norbertBergmann?

josealvarez97 commented 1 year ago

I ended creating my own custom unique IDs, which I store as properties in the relationships.

Still, it would be nice to be able to add the @cypher directive to relationships. It would be useful, for example, to query the type function on a relationship.