graphql/utilities 模块包含与 GraphQL 语言和类型对象一起使用的常见有用计算。您可以从 graphql/utilities 模块或根 graphql 模块导入。例如
import { introspectionQuery } from "graphql" // ES6var { introspectionQuery } = require("graphql") // CommonJS
内省
模式语言
访问者
值验证
var introspectionQuery: string
一个 GraphQL 查询,它查询服务器的内省系统以获取足够的信息来重现该服务器的类型系统。
function buildClientSchema(  introspection: IntrospectionQuery): GraphQLSchema
构建供客户端工具使用的 GraphQLSchema。
给定客户端运行内省查询的结果,创建并返回一个 GraphQLSchema 实例,该实例可用于所有 GraphQL.js 工具,但不能用于执行查询,因为内省不代表“解析器”、“解析”或“序列化”函数或任何其他服务器内部机制。
function buildSchema(source: string | Source): GraphQLSchema {
从 GraphQL 模式语言创建 GraphQLSchema 对象。该模式将使用默认解析器。有关 GraphQL 模式语言的更多详细信息,请参阅模式语言文档或此模式语言速查表。
function printSchema(schema: GraphQLSchema): string {
以模式语言格式打印提供的模式。
function printIntrospectionSchema(schema: GraphQLSchema): string {
以模式语言格式打印内置内省模式。
function buildASTSchema(  ast: SchemaDocument,  queryTypeName: string,  mutationTypeName: ?string): GraphQLSchema
这将采用由 graphql/language/schema 中的 parseSchemaIntoAST 生成的模式文档的 ast,并构建一个 GraphQLSchema 实例,该实例可用于所有 GraphQL.js 工具,但不能用于执行查询,因为内省不代表“解析器”、“解析”或“序列化”函数或任何其他服务器内部机制。
function typeFromAST(  schema: GraphQLSchema,  inputTypeAST: Type): ?GraphQLType
给定类型在 GraphQL AST 中出现的名称和模式,从该模式返回相应的 GraphQLType。
function astFromValue(  value: any,  type: GraphQLInputType): ?Value
根据 JavaScript 值生成 GraphQL 输入值 AST。
可选地,可以提供 GraphQL 类型,这将用于区分值基元。
class TypeInfo {  constructor(schema: GraphQLSchema)  getType(): ?GraphQLOutputType {  getParentType(): ?GraphQLCompositeType {  getInputType(): ?GraphQLInputType {  getFieldDef(): ?GraphQLFieldDefinition {  getDirective(): ?GraphQLDirective {  getArgument(): ?GraphQLArgument {}
TypeInfo 是一个实用程序类,它在给定 GraphQL 模式的情况下,可以通过调用 enter(node) 和 leave(node) 来跟踪 GraphQL 文档 AST 中任何点的当前字段和类型定义。
function isValidJSValue(value: any, type: GraphQLInputType): string[]
给定一个 JavaScript 值和一个 GraphQL 类型,确定该值是否会被该类型接受。这主要用于验证查询变量的运行时值。
function isValidLiteralValue(  type: GraphQLInputType,  valueAST: Value): string[]
用于验证器的实用程序,它确定给定输入类型,值文字 AST 是否有效。
请注意,这仅验证文字值,变量被假定为提供正确类型的值。