Help us shape the future of Go! Take the 2026 Go Developer Survey

astprinter

package
v2.30.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 29, 2026 License: MIT Imports: 6 Imported by: 10

Documentation

Overview

Package astprinter takes a GraphQL document and prints it as a String with optional indentation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Print

func Print(document *ast.Document, out io.Writer) error

Print takes a document as well as a definition (optional) and prints it to the io.Writer. The definition is only necessary in case a GraphQL Operation should be printed.

func PrintIndent

func PrintIndent(document *ast.Document, indent []byte, out io.Writer) error

PrintIndent is the same as Print but accepts an additional indent parameter to set indentation. Indent is written once for every depth level.

func PrintIndentDebug

func PrintIndentDebug(document *ast.Document, indent []byte, out io.Writer, callback ...func(fieldRef int, out io.Writer)) error

PrintIndentDebug is the same as PrintIndent but calls the function for every field.

func PrintString

func PrintString(document *ast.Document) (string, error)

PrintString is the same as Print but returns a string instead of writing to an io.Writer

func PrintStringIndent

func PrintStringIndent(document *ast.Document, indent string) (string, error)

PrintStringIndent is the same as PrintIndent but returns a string instead of writing to an io.Writer

func PrintStringIndentDebug

func PrintStringIndentDebug(document *ast.Document, indent string, callback ...func(fieldRef int, out io.Writer)) (string, error)

PrintStringIndentDebug is the same as PrintStringIndent but prints debug information

Types

type Printer

type Printer struct {
	// contains filtered or unexported fields
}

Printer walks a GraphQL document and prints it as a string

func NewPrinter

func NewPrinter(indent []byte) *Printer

func (*Printer) Print

func (p *Printer) Print(document *ast.Document, out io.Writer) error

Print starts the actual AST printing Keep a printer and re-use it in case you'd like to print ASTs in the hot path.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL