GraphQL规范

GraphQL规范

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

内置类型

  • ID: 表示唯一标识符,通常用于对象的重取或缓存键。
  • String: 表示文本数据,可读的字符串。
  • Boolean:布尔
  • Float:表示双精度浮点数。
  • Int: 整数
python 复制代码
"""
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。
python 复制代码
"""
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中定义的类型和结构。

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
}
相关推荐
Theodore_1022几秒前
4 设计模式原则之接口隔离原则
java·开发语言·设计模式·java-ee·接口隔离原则·javaee
----云烟----2 小时前
QT中QString类的各种使用
开发语言·qt
lsx2024062 小时前
SQL SELECT 语句:基础与进阶应用
开发语言
开心工作室_kaic2 小时前
ssm161基于web的资源共享平台的共享与开发+jsp(论文+源码)_kaic
java·开发语言·前端
向宇it2 小时前
【unity小技巧】unity 什么是反射?反射的作用?反射的使用场景?反射的缺点?常用的反射操作?反射常见示例
开发语言·游戏·unity·c#·游戏引擎
武子康3 小时前
Java-06 深入浅出 MyBatis - 一对一模型 SqlMapConfig 与 Mapper 详细讲解测试
java·开发语言·数据仓库·sql·mybatis·springboot·springcloud
转世成为计算机大神3 小时前
易考八股文之Java中的设计模式?
java·开发语言·设计模式
宅小海3 小时前
scala String
大数据·开发语言·scala
qq_327342733 小时前
Java实现离线身份证号码OCR识别
java·开发语言
锅包肉的九珍3 小时前
Scala的Array数组
开发语言·后端·scala