简体   繁体   English

我想如何在neo4j graphql js中使用自定义查询返回关系类型

[英]How do I suppose to do to return a relation type with custom query in neo4j graphql js

So I have a schema like this:所以我有一个这样的架构:

type NetZone {
  name: String
  version: String
  hasAccessTo: [HasAccess]
}

type HasAccess @relation(name: "HasAccess") {
from: NetZone
to: NetZone
version: String
}

So there is a "HasAccess" connect to "NetZone" itself, and that cause unexpected generated querties, like, totally unacceptable result, so I change to use custom query, and change type NetZone to something like this:所以有一个“HasAccess”连接到“NetZone”本身,这会导致意外生成的查询,比如完全不可接受的结果,所以我改用自定义查询,并将 NetZone 类型更改为如下所示:

type NetZone {
  name: String
  version: String
  hasAccessTo(first: Int = 10, offset: Int = 0): [NetZone] @cypher(statement: "MATCH (this)-[r:HasAccess]->(target:NetZone) RETURN target SKIP $offset LIMIT $first")
}

So now it is working.所以现在它正在工作。 But I really want to return something like this:但我真的很想返回这样的东西:

type _HasAccess {
  version: String
  netZone: NetZone
}

is there any way to achieve this, or a way to fix the first unexpected result?有什么办法可以做到这一点,或者有办法解决第一个意想不到的结果吗?

So I have a schema like this:所以我有一个这样的架构:

type NetZone {
  name: String
  version: String
  hasAccessTo: [HasAccess]
}

type HasAccess @relation(name: "HasAccess") {
from: NetZone
to: NetZone
version: String
}

So there is a "HasAccess" connect to "NetZone" itself, and that cause unexpected generated querties, like, totally unacceptable result, so I change to use custom query, and change type NetZone to something like this:所以有一个“HasAccess”连接到“NetZone”本身,这会导致意外生成的查询,比如完全不可接受的结果,所以我改用自定义查询,并将 NetZone 类型更改为如下所示:

type NetZone {
  name: String
  version: String
  hasAccessTo(first: Int = 10, offset: Int = 0): [NetZone] @cypher(statement: "MATCH (this)-[r:HasAccess]->(target:NetZone) RETURN target SKIP $offset LIMIT $first")
}

So now it is working.所以现在它正在工作。 But I really want to return something like this:但我真的很想返回这样的东西:

type _HasAccess {
  version: String
  netZone: NetZone
}

is there any way to achieve this, or a way to fix the first unexpected result?有什么办法可以做到这一点,或者有办法解决第一个意想不到的结果吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM