类型配置
这是 GraphQL 库版本 6 的文档。对于长期支持 (LTS) 版本 5,请参阅 GraphQL 库版本 5 LTS。 |
在表示 Neo4j 节点时,GraphQL 对象类型在查询、变异和订阅类型中生成多个操作字段。例如
type Movie @node {
title: String
length: Int
}
从这些类型定义中,库生成以下操作字段
查询:
-
movies
-
moviesAggregate
-
moviesConnection
变异:
-
createMovies
-
deleteMovies
-
updateMovies
订阅:
-
movieCreated
-
movieUpdated
-
movieDeleted
.
此页面介绍如何使用指令 @query
、@mutation
和 @subscription
减少生成的操纵字段。
@query
@mutation
@subscription
@default
在为 create
变异生成输入类型时,此指令中指定的值用作该字段的默认值。
定义
"""Int | Float | String | Boolean | ID | DateTime | Enum"""
scalar Scalar
"""Instructs @neo4j/graphql to set the specified value as the default value in the CreateInput type for the object type in which this directive is used."""
directive @default(
"""The default value to use. Must be a scalar type and must match the type of the field with which this directive decorates."""
value: Scalar!,
) on FIELD_DEFINITION