当前位置: 首页 > article >正文

GraphQL规范

GraphQL规范

  • 内置类型
  • 内置指令
  • 自省

对IDEA插件GraphQL生成的规范的总结。详细规范文档请参阅GraphQL规范

内置类型

  • ID: 表示唯一标识符,通常用于对象的重取或缓存键。
  • String: 表示文本数据,可读的字符串。
  • Boolean:布尔
  • Float:表示双精度浮点数。
  • Int: 整数

"""
The ID scalar type represents a unique identifier, often used to refetch an object or as key for a cache.
The ID type appears in a JSON response as a String; however, it is not intended to be human-readable.
When expected as an input type, any string (such as "4") or integer (such as 4) input value will be accepted as an ID.
"""
scalar ID

"""
The String scalar type represents textual data, represented as UTF-8 character sequences.
The String type is most often used by GraphQL to represent free-form human-readable text.
"""
scalar String

"""
The Boolean scalar type represents true or false.
"""
scalar Boolean

"""
The Float scalar type represents signed double-precision fractional values as specified by IEEE 754.
"""
scalar Float

"""
The Int scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.
"""
scalar Int

内置指令

  • @include: 允许在执行期间条件性地包含字段。
  • @skip: 允许在执行期间条件性地排除字段。
  • @deprecated: 指示某些部分已弃用,并提供原因。
  • @specifiedBy: 提供自定义标量的行为说明的URL。
"""
The @include directive may be provided for fields, fragment spreads, and inline fragments,
and allows for conditional inclusion during execution as described by the if argument.
"""
directive @include(if: Boolean!) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT


"""
The @skip directive may be provided for fields, fragment spreads, and inline fragments,
and allows for conditional exclusion during execution as described by the if argument.
"""
directive @skip(if: Boolean!) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT


"""
The @deprecated directive is used within the type system definition language to indicate deprecated portions of a
GraphQL service's schema, such as deprecated fields, enum values, arguments or input fields.

Deprecations include a reason for why it is deprecated, which is formatted using Markdown syntax (as specified by CommonMark).
"""
directive @deprecated(reason: String = "No longer supported") on FIELD_DEFINITION | ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION | ENUM_VALUE

"""
The @specifiedBy directive is used within the type system definition language
to provide a URL for specifying the behavior of custom scalar definitions.
"""
directive @specifiedBy(url: String!) on SCALAR

自省

对GraphQL服务的查询,使得客户端可以动态理解和查询GraphQL中定义的类型和结构。


type __QueryIntrospectionMeta {
    __schema: __Schema!
    __type(name: String!): __Type
}

type __TypeNameMeta {
    __typename: String!
}

type __Schema {
    description: String
    types: [__Type!]!
    queryType: __Type!
    mutationType: __Type
    subscriptionType: __Type
    directives: [__Directive!]!
}

type __Type {
    kind: __TypeKind!
    name: String
    description: String

    "OBJECT and INTERFACE only"
    fields(includeDeprecated: Boolean = false): [__Field!]

    "OBJECT only"
    interfaces: [__Type!]

    "INTERFACE and UNION only"
    possibleTypes: [__Type!]

    "ENUM only"
    enumValues(includeDeprecated: Boolean = false): [__EnumValue!]

    "INPUT_OBJECT only"
    inputFields(includeDeprecated: Boolean = false): [__InputValue!]

    "NON_NULL and LIST only"
    ofType: __Type

    "May be non-null for custom SCALAR, otherwise null"
    specifiedByURL: String
}

type __Field {
    name: String!
    description: String
    args(includeDeprecated: Boolean = false): [__InputValue!]!
    type: __Type!
    isDeprecated: Boolean!
    deprecationReason: String
}

type __InputValue {
    name: String!
    description: String
    type: __Type!
    defaultValue: String
    isDeprecated: Boolean!
    deprecationReason: String
}

type __EnumValue {
    name: String!
    description: String
    isDeprecated: Boolean!
    deprecationReason: String
}

enum __TypeKind {
    SCALAR,
    OBJECT,
    INTERFACE,
    UNION,
    ENUM,
    INPUT_OBJECT,
    LIST,
    NON_NULL,
}

type __Directive {
    name: String!
    description: String
    locations: [__DirectiveLocation!]!
    args(includeDeprecated: Boolean = false): [__InputValue!]!
    isRepeatable: Boolean!
}

enum __DirectiveLocation {
    QUERY
    MUTATION
    SUBSCRIPTION
    FIELD
    FRAGMENT_DEFINITION
    FRAGMENT_SPREAD
    INLINE_FRAGMENT
    VARIABLE_DEFINITION
    SCHEMA
    SCALAR
    OBJECT
    FIELD_DEFINITION
    ARGUMENT_DEFINITION
    INTERFACE
    UNION
    ENUM
    ENUM_VALUE
    INPUT_OBJECT
    INPUT_FIELD_DEFINITION
}

http://www.kler.cn/news/323910.html

相关文章:

  • C++动态内存管理
  • 基于大数据的亚健康人群数据分析及可视化系统
  • GEE 教程:如何在谷歌地球引擎中使用克里金插值?
  • ArcGIS Pro高级地图可视化—双变量符号地图
  • 极品飞车14热力追踪原始版高清重制版MOD分享
  • QT开发:深入详解Qt 核心类QTimer的概念及应用
  • Linux网络之UDP与TCP协议详解
  • wpf在图上画矩形,矩形可拖动、大小可调节,使用装饰器Adorner调整矩形大小,限制拖动和调节范围
  • Go语言流程控制
  • “AI+Security”系列第3期(四):360安全大模型业务实践
  • 一文上手Kafka【中】
  • 叉车高位显示器无线摄影,安装更加便捷!
  • 从“纸面算力”到“好用算力”,超聚变打通AI+“最后一公里”
  • RabbitMQ高级特性-重试机制
  • 备考中考的制胜法宝 —— 全国历年中考真题试卷大全
  • 【C++笔记】初始模版和STL简介
  • Python项目周报
  • ChatGPT 提取文档内容,高效制作PPT、论文
  • vue2 页面强制渲染
  • 计算机毕业设计电影票购买网站 在线选票选座 场次订票统计 新闻留言搜索/springboot/javaWEB/J2EE/MYSQL数据库/vue前后分离小程序
  • 【C++拓展(四)】秋招建议与心得
  • QEMU 用户网络与桥接网络设置总结
  • ubuntu22.04磁盘挂载(多磁盘和单磁盘挂载)
  • 讯飞星火编排创建智能体学习(一)最简单的智能体构建
  • 什么是触发器(Trigger)?触发器何时会被触发?
  • MYSQL(学习笔记)
  • K8s flink-operator 例子
  • [大语言模型-论文精读] Diffusion Model技术-通过时间和空间组合扩散模型生成复杂的3D人物动作
  • k8s中,服务的自动注册、自动感知、负载均衡,三个功能的含义及测试验证
  • 前端面试题(十)