graphql

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package graphql implements a GraphQL schema parser.

Index

Constants

This section is empty.

Variables

View Source
var GraphQLLexer = lexer.MustSimple([]lexer.SimpleRule{
	{"Whitespace", `[ \t\r\n]+`},
	{"Comment", `#[^\n]*`},
	{"String", `"[^"]*" `},
	{"Ident", `[A-Za-z_][A-Za-z0-9_]*`},
	{"Number", `-?[0-9]+(\.[0-9]+)?`},
	{"Symbol", `[()\[\]{}:,|]`},
	{"Operator", `[=!@&]`},
})

GraphQLLexer defines the GraphQL lexer configuration.

Functions

This section is empty.

Types

type FieldDefinition

type FieldDefinition struct {
	Name string `@Ident`
	Type string `@(":" @Ident)`
}

FieldDefinition represents a GraphQL field definition.

type Parser

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

Parser implements a GraphQL schema parser.

func NewParser

func NewParser() (*Parser, error)

NewParser creates a new GraphQL parser.

func (*Parser) ParseSchema

func (p *Parser) ParseSchema(_ context.Context, schema string) (*model.Catalog, error)

ParseSchema parses a GraphQL schema and returns a catalog.

func (*Parser) Validate

func (p *Parser) Validate(schema string) ([]string, error)

Validate validates a GraphQL schema and returns any issues.

type Schema

type Schema struct {
	Types []*TypeDefinition `@@*`
}

Schema represents a parsed GraphQL schema.

type TypeDefinition

type TypeDefinition struct {
	Name   string             `@("type" @Ident)`
	Fields []*FieldDefinition `"{" @@+ "}"`
}

TypeDefinition represents a GraphQL type definition.

Jump to

Keyboard shortcuts

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