GraphQL.JS 文档
graphql

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

标量

¥Scalars

错误

¥Errors

入口点

¥Entry Point

graphql

function graphql(
  schema: GraphQLSchema,
  requestString: string,
  rootValue?: any,
  contextValue?: any,
  variableValues?: {[key: string]: any},
  operationName?: string
): Promise<GraphQLResult>

graphql 函数对 GraphQL 请求进行词法分析、解析、验证和执行。它需要 schemarequestString。可选参数包括 rootValue,它将作为根值传递给执行器;contextValue,它将传递给所有解析函数;variableValues,它将传递给执行器,为 requestStringoperationName 中的任何变量提供值。 ,它允许调用者指定在 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