Sign in

    moonbitstack/moongql/lang does not have a README file

    GqlSyntaxError

    pub suberror GqlSyntaxError {
    GqlSyntaxError(String, Int, Int)
    }

    A syntax error raised by the lexer or parser, carrying a message and the 1-based line/column where the offending token starts.

    GqlSyntaxError::output

    fn GqlSyntaxError::output(self : GqlSyntaxError, logger : &Logger) -> Unit

    GqlSyntaxError::to_string

    fn GqlSyntaxError::to_string(self : GqlSyntaxError) -> String

    Render a syntax error as Syntax error at L:C: message.

    Argument

    pub(all) struct Argument {
    name : String
    value : Value
    pos : Pos
    }

    A name: value argument on a field or directive.

    Definition

    pub(all) enum Definition {
    OperationDef(OperationDefinition)
    FragmentDef(FragmentDefinition)
    }

    A top-level executable definition: an operation or a named fragment.

    Directive

    pub(all) struct Directive {
    name : String
    arguments : Array[Argument]
    pos : Pos
    }

    A directive application: @name(args).

    Document

    pub(all) struct Document {
    definitions : Array[Definition]
    }

    A parsed GraphQL document: an ordered list of executable definitions.

    Document::to_query

    fn Document::to_query(self : Document) -> String

    Print a whole document back to a canonical GraphQL string: each definition, separated by a blank line. Parsing this output yields an equivalent AST.

    FragmentDefinition

    pub(all) struct FragmentDefinition {
    name : String
    type_condition : String
    directives : Array[Directive]
    selection_set : Array[Selection]
    pos : Pos
    }

    A named fragment definition: fragment Name on Type @dir { selection }.

    GqlError

    pub(all) struct GqlError {
    message : String
    path : Array[Json]
    locations : Array[Pos]
    extensions : Map[String, Json]
    }

    A GraphQL error entry: a message, an optional response path (string field keys and integer list indices), and optional source locations.

    GqlError::at

    fn GqlError::at(message : String, pos : Pos) -> GqlError

    Build an error carrying a message and the position of the node it is about. ยง7.1.2 requires locations on every error that can name one.

    GqlError::msg

    fn GqlError::msg(message : String) -> GqlError

    Build an error carrying only a message, for the request-level failures that cannot be pinned to a point in the document (an empty document, an unknown operation name).

    GqlError::to_json

    fn GqlError::to_json(self : GqlError) -> Json

    Serialise an error to the GraphQL JSON error shape, omitting an empty path or locations list.

    OperationDefinition

    pub(all) struct OperationDefinition {
    operation : OperationType
    name : String?
    variable_definitions : Array[VariableDefinition]
    directives : Array[Directive]
    selection_set : Array[Selection]
    pos : Pos
    }

    An operation: its type, an optional name, variable definitions, directives and a selection set. The anonymous { ... } query shorthand parses to an OperationDefinition with operation = Query and name = None.

    OperationType

    pub(all) enum OperationType {
    Query
    Mutation
    Subscription
    } derive(Eq)

    Which kind of operation a definition describes.

    OperationType::equal

    OperationType::not_equal

    fn OperationType::not_equal(x : OperationType, y : OperationType) -> Bool

    Pos

    pub(all) struct Pos {
    line : Int
    col : Int
    } derive(Eq)

    The 1-based line and column of a node's first token. Every node an error can point back at carries one, so a validation or field error can answer with the locations entry the spec requires (ยง7.1.2).

    Pos::equal

    fn Pos::equal(Pos, Pos) -> Bool

    Pos::not_equal

    fn Pos::not_equal(x : Pos, y : Pos) -> Bool

    QueryField

    pub(all) struct QueryField {
    alias_ : String?
    name : String
    arguments : Array[Argument]
    directives : Array[Directive]
    selection_set : Array[Selection]
    pos : Pos
    }

    A queried field: an optional alias, the field name, arguments, directives and an optional nested selection set. Prints as alias: name(args) @dir { ... }.

    Selection

    pub(all) enum Selection {
    FieldSel(QueryField)
    FragmentSpreadSel(String, Array[Directive], Pos)
    InlineFragmentSel(String?, Array[Directive], Array[Selection], Pos)
    }

    One entry in a selection set: a field, a ...Name fragment spread, or an inline ... on Type { ... } fragment.

    Token

    pub(all) struct Token {
    kind : TokenKind
    value : String
    line : Int
    col : Int
    }

    A lexical token: its kind, its text (for value-bearing kinds; unescaped for strings), and the 1-based line/column of its first character.

    TokenKind

    pub(all) enum TokenKind {
    Name
    IntVal
    FloatVal
    StringVal
    BlockStringVal
    Bang
    Dollar
    Amp
    ParenL
    ParenR
    Spread
    Colon
    Equals
    At
    BracketL
    BracketR
    BraceL
    BraceR
    Pipe
    Eof
    } derive(Eq)

    The lexical category of a token. Value-bearing kinds (Name, IntVal, FloatVal, StringVal, BlockStringVal) carry their text in Token::value.

    TokenKind::equal

    fn TokenKind::equal(TokenKind, TokenKind) -> Bool

    TokenKind::not_equal

    fn TokenKind::not_equal(x : TokenKind, y : TokenKind) -> Bool

    TypeRef

    pub(all) enum TypeRef {
    NamedType(String)
    ListType(TypeRef)
    NonNullType(TypeRef)
    } derive(Eq)

    A type reference as it appears in the query grammar: a named type, a list wrapper [T], or a non-null wrapper T!. Distinct from the schema builder's GqlType (which carries a Scalar sugar the parser never sees).

    TypeRef::equal

    fn TypeRef::equal(TypeRef, TypeRef) -> Bool

    TypeRef::not_equal

    fn TypeRef::not_equal(x : TypeRef, y : TypeRef) -> Bool

    TypeRef::to_query

    fn TypeRef::to_query(self : TypeRef) -> String

    Print a type reference back to GraphQL notation ([Int!]!).

    Value

    pub(all) enum Value {
    Variable(String)
    IntValue(String)
    FloatValue(String)
    StringValue(String, Bool)
    BooleanValue(Bool)
    NullValue
    EnumValue(String)
    ListValue(Array[Value])
    ObjectValue(Array[(String, Value)])
    }

    A GraphQL input value. Numeric and string literals keep their source text (matching graphql-core, whose IntValueNode.value etc. are strings), so no lossy numeric round-trip is baked into the AST. StringValue's second field is the block-string flag.

    Value::to_query

    fn Value::to_query(self : Value) -> String

    Print a value back to GraphQL literal syntax.

    VariableDefinition

    pub(all) struct VariableDefinition {
    variable : String
    typ : TypeRef
    default_value : Value?
    directives : Array[Directive]
    pos : Pos
    }

    A variable declaration in an operation's (...) list: $name: Type = default with optional default value and directives.

    collect_fragments

    fn collect_fragments(doc : Document) -> Map[String, FragmentDefinition]

    Build the document's fragment table by name.

    escape_string

    fn escape_string(s : String) -> String

    Escape a string's contents for printing inside GraphQL double quotes.

    parse

    fn parse(source : String) -> Document raise GqlSyntaxError

    Parse a GraphQL executable document from source text. This is the front half of the executor: parse(query).definitions yields the operations and fragments to validate and execute.

    tokenize

    fn tokenize(src : String) -> Array[Token] raise GqlSyntaxError

    Tokenize an entire source string into a token array ending with Eof. Primarily for tests and tooling; the parser pulls tokens on demand.

    Powered by MoonBit

    Site sourceReport issuePackagesBuild queueSkillsStatistics

    ยฉ 2026 mooncakes.io