迁移到 5.0.0

此页面列出了 Neo4j GraphQL 库版本 4.x 到 5.x 的所有重大更改以及如何更新它。

如何更新

要更新您的 Neo4j GraphQL 库,请使用 npm 或您选择的包管理器。

npm update @neo4j/graphql

重大更改

以下是版本 4.0.0 到 5.0.0 的所有重大更改列表。

@relationshipProperties

现在应在类型而不是接口上使用指令 @relationshipProperties。例如

之前 现在
interface ActedIn @relationshipProperties {
    screenTime: Int
}

type Movie {
    title: String
    actors: [Person!]! @relationship(type: "ACTED_IN", direction: IN, properties: "ActedIn")
}

type Person {
    name: String
}
type ActedIn @relationshipProperties {
    screenTime: Int
}

type Movie {
    title: String
    actors: [Person!]! @relationship(type: "ACTED_IN", direction: IN, properties: "ActedIn")
}

type Person {
    name: String
}

接口指令

为了更好地匹配 GraphQL 的默认行为,用于接口的库指令将不再级联到实现类型。这意味着大多数指令在接口中不再有效,必须在实现类型中定义。这也适用于自定义指令。

@declareRelationship

指令 @relationship 在接口中不再可用。如果您需要在接口上使用关系,则需要改用新的 @declareRelationship 指令,以及在具体类型中定义关系。

此更改是由于指令不再从接口级联到类型。但是,现在关系可以在每个类型中具有不同的属性和标签。例如

之前

现在

interface Production {
    title: String!
    actors: [Actor!]! @relationship(type: "ACTED_IN", direction: IN)
}

type Movie implements Production {
    title: String!
    actors: [Actor!]!
}

type Series implements Production {
    title: String!
    episodes: Int!
    actors: [Actor!]!
}

type Actor {
    name: String!
}
interface Production {
    title: String!
    actors: [Actor!]! @declareRelationship
}

type Movie implements Production {
    title: String!
    actors: [Actor!]! @relationship(type: "ACTED_IN", direction: IN)
}

type Series implements Production {
    title: String!
    episodes: Int!
    actors: [Actor!]! @relationship(type: "ACTED_IN", direction: IN)
}

type Actor {
    name: String!
}

边属性

连接中的边属性现在存在于 edges 中的 properties 字段内。

之前

现在

query ActedInConnection {
  actors {
    actedInConnection {
      edges {
          screenTime
      }
    }
  }
}
query ActedInConnection {
  actors {
    actedInConnection {
      edges {
        properties {
          screenTime
        }
      }
    }
  }
}

_on 过滤器已弃用

接口的 _on 过滤器在 where 和变异中不再可用。要按实现类型进行过滤,您需要使用新的过滤器 typename_IN

之前

现在

query MyQuery {
  actors(
    where: {
      actedInConnection_SINGLE: { node: { _on: { Movie: { } } } }
    }
  ) {
    name
  }
}
query MyQuery {
 actors(
    where: {
      actedInConnection_SINGLE: { node: { typename_IN: [Movie] } }
    }
  ) {
    name
  }
}

不再支持在接口操作中使用类型的字段。

最低 NodeJS 版本

随着 Node 16 的弃用,最低支持的 NodeJS 版本为 18.0.0

experimental 标志

Neo4jGraphQL 类选项中不再提供 experimental 标志。