GraphQL: Utilities Module Cheat Sheet

Introspection

introspectionQuery

A GraphQL introspection query containing enough information to reproduce a type system.

var introspectionQuery: string

buildClientSchema 

Produces a client schema given the result of querying a schema with `introspectionQuery`.

function buildClientSchema(
  introspection: IntrospectionQuery
): GraphQLSchema

Build a GraphQLSchema for use by client tools.

Schema Representation 

buildSchema 

Builds a Schema object from GraphQL schema language.

function buildSchema(source: string | Source): GraphQLSchema {

printSchema 

Prints the schema in a standard format.

function printSchema(schema: GraphQLSchema): string {

printIntrospectionSchema 

Prints the introspection features of the schema in a standard format.

function printIntrospectionSchema(schema: GraphQLSchema): string {

buildASTSchema 

Builds a schema from a parsed AST Schema.

function buildASTSchema(
  ast: SchemaDocument,
  queryTypeName: string,
  mutationTypeName: ?string
): GraphQLSchema

typeFromAST 

Looks up a type referenced in an AST in the GraphQLSchema.

function typeFromAST(
  schema: GraphQLSchema,
  inputTypeAST: Type
): ?GraphQLType

astFromValue 

Produces a GraphQL Input Value AST given a JavaScript value.

function astFromValue(
  value: any,
  type?: ?GraphQLType
): ?Value

Visitors 

TypeInfo 

Tracks type and field definitions during a visitor AST traversal..

class TypeInfo {
  constructor(schema: GraphQLSchema)
  getType(): ?GraphQLOutputType {
  getParentType(): ?GraphQLCompositeType {
  getInputType(): ?GraphQLInputType {
  getFieldDef(): ?GraphQLFieldDefinition {
  getDirective(): ?GraphQLDirective {
  getArgument(): ?GraphQLArgument {
}

Value Validation

isValidJSValue 

Determines if a JavaScript value is valid for a GraphQL type.

function isValidJSValue(value: any, type: GraphQLInputType): string[]

isValidLiteralValue 

Determines if a literal value from an AST is valid for a GraphQL type.

function isValidLiteralValue(
  type: GraphQLInputType,
  valueAST: Value
): string[]

Leave a Reply

Your email address will not be published. Required fields are marked *