类型配置
在表示 Neo4j 节点时,GraphQL 对象类型会在查询、变异和订阅类型中生成多个操作字段。例如
type Movie {
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