graphql
graphql
模块导出 GraphQL 功能的核心子集,用于创建 GraphQL 类型系统和服务器。
¥The graphql
module exports a core subset of GraphQL functionality for creation
of GraphQL type systems and servers.
import { graphql } from "graphql" // ES6
var { graphql } = require("graphql") // CommonJS
概述
¥Overview
入口点
¥Entry Point
结构
¥Schema
类型定义
¥Type Definitions
class GraphQLScalarType
GraphQL 中的标量类型。¥
class GraphQLScalarType
A scalar type within GraphQL.class GraphQLObjectType
GraphQL 中包含字段的对象类型。¥
class GraphQLObjectType
An object type within GraphQL that contains fields.class GraphQLInterfaceType
GraphQL 中定义字段实现将包含的接口类型。¥
class GraphQLInterfaceType
An interface type within GraphQL that defines fields implementations will contain.class GraphQLUnionType
GraphQL 中的联合类型,定义实现列表。¥
class GraphQLUnionType
A union type within GraphQL that defines a list of implementations.class GraphQLEnumType
GraphQL 中定义有效值列表的枚举类型。¥
class GraphQLEnumType
An enum type within GraphQL that defines a list of valid values.class GraphQLInputObjectType
GraphQL 中表示结构化输入的输入对象类型。¥
class GraphQLInputObjectType
An input object type within GraphQL that represents structured inputs.class GraphQLList
表示这些类型列表的其他类型的类型封装器。¥
class GraphQLList
A type wrapper around other types that represents a list of those types.class GraphQLNonNull
表示这些类型的非空版本的其他类型的类型封装器。¥
class GraphQLNonNull
A type wrapper around other types that represents a non-null version of those types.
标量
¥Scalars
var GraphQLInt
表示整数的标量类型。¥
var GraphQLInt
A scalar type representing integers.var GraphQLFloat
表示浮点数的标量类型。¥
var GraphQLFloat
A scalar type representing floats.var GraphQLString
表示字符串的标量类型。¥
var GraphQLString
A scalar type representing strings.var GraphQLBoolean
表示布尔值的标量类型。¥
var GraphQLBoolean
A scalar type representing booleans.var GraphQLID
表示 ID 的标量类型。¥
var GraphQLID
A scalar type representing IDs.
错误
¥Errors
入口点
¥Entry Point
graphql
function graphql(
schema: GraphQLSchema,
requestString: string,
rootValue?: any,
contextValue?: any,
variableValues?: {[key: string]: any},
operationName?: string
): Promise<GraphQLResult>
graphql
函数对 GraphQL 请求进行词法分析、解析、验证和执行。它需要 schema
和 requestString
。可选参数包括 rootValue
,它将作为根值传递给执行器;contextValue
,它将传递给所有解析函数;variableValues
,它将传递给执行器,为 requestString
和 operationName
中的任何变量提供值。 ,它允许调用者指定在 requestString
包含多个顶层操作的情况下将运行 requestString
中的哪个操作。
¥The graphql
function lexes, parses, validates and executes a GraphQL request.
It requires a schema
and a requestString
. Optional arguments include a
rootValue
, which will get passed as the root value to the executor, a contextValue
,
which will get passed to all resolve functions,
variableValues
, which will get passed to the executor to provide values for
any variables in requestString
, and operationName
, which allows the caller
to specify which operation in requestString
will be run, in cases where
requestString
contains multiple top-level operations.
结构
¥Schema
参见 类型系统 API 参考。
¥See the Type System API Reference.
类型定义
¥Type Definitions
参见 类型系统 API 参考。
¥See the Type System API Reference.
标量
¥Scalars
参见 类型系统 API 参考。
¥See the Type System API Reference.
错误
¥Errors
参见 错误 API 参考
¥See the Errors API Reference