Sign in

    moonbit-community/graphql/parser does not have a README file

    ParseError

    pub(all) suberror ParseError {
    GraphQLParseError(String, Pos)
    } derive(Eq)

    Error raised by tokenizer, query parser, and schema parser.

    Each parse error carries the source position where parsing failed.
    impl Show for ParseError

    ParseError::equal

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

    ParseError::not_equal

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

    ParseError::output

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

    ParseError::to_string

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

    Render a parse error with line and column context.

    Directive

    pub(all) struct Directive {
    position : Pos
    name : String
    arguments : Array[(String, Value)]
    } derive(Eq,
    Debug
    )

    GraphQL directive use with parsed arguments.

    Directive::equal

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

    Directive::not_equal

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

    DirectiveDefinition

    pub(all) struct DirectiveDefinition {
    position : Pos
    description : String?
    name : String
    arguments : Array[InputValue]
    repeatable : Bool
    locations : Array[DirectiveLocation]
    } derive(Eq,
    Debug
    )

    SDL directive definition.

    DirectiveDefinition::equal

    DirectiveDefinition::not_equal

    DirectiveLocation

    pub(all) enum DirectiveLocation {
    LocationQuery
    LocationMutation
    LocationSubscription
    LocationField
    LocationFragmentDefinition
    LocationFragmentSpread
    LocationInlineFragment
    LocationSchema
    LocationScalar
    LocationObject
    LocationFieldDefinition
    LocationArgumentDefinition
    LocationInterface
    LocationUnion
    LocationEnum
    LocationEnumValue
    LocationInputObject
    LocationInputFieldDefinition
    LocationVariableDefinition
    } derive(Eq,
    Debug
    )

    GraphQL directive location.

    DirectiveLocation::as_string

    fn DirectiveLocation::as_string(self : DirectiveLocation) -> String

    Return the canonical GraphQL spec name for a directive location.

    DirectiveLocation::equal

    DirectiveLocation::is_query

    fn DirectiveLocation::is_query(self : DirectiveLocation) -> Bool

    Return true when this location belongs to executable GraphQL documents.

    DirectiveLocation::is_schema

    fn DirectiveLocation::is_schema(self : DirectiveLocation) -> Bool

    Return true when this location belongs to GraphQL SDL.

    DirectiveLocation::not_equal

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

    EnumType

    pub(all) struct EnumType {
    position : Pos
    description : String?
    name : String
    directives : Array[Directive]
    values : Array[EnumValue]
    } derive(Eq,
    Debug
    )

    SDL enum type definition.

    EnumType::equal

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

    EnumType::not_equal

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

    EnumType::to_repr

    EnumTypeExtension

    pub(all) struct EnumTypeExtension {
    position : Pos
    name : String
    directives : Array[Directive]
    values : Array[EnumValue]
    } derive(Eq,
    Debug
    )

    SDL enum type extension.

    EnumTypeExtension::equal

    EnumTypeExtension::not_equal

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

    EnumValue

    pub(all) struct EnumValue {
    position : Pos
    description : String?
    name : String
    directives : Array[Directive]
    } derive(Eq,
    Debug
    )

    SDL enum value definition.

    EnumValue::equal

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

    EnumValue::not_equal

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

    Field

    pub(all) struct Field {
    position : Pos
    field_alias : String?
    name : String
    arguments : Array[(String, Value)]
    directives : Array[Directive]
    selection_set : SelectionSet
    } derive(Eq,
    Debug
    )

    Field selection with optional alias, arguments, directives, and nested selection set.

    Field::equal

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

    Field::not_equal

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

    Field::to_repr

    FragmentDefinition

    pub(all) struct FragmentDefinition {
    position : Pos
    name : String
    type_condition : TypeCondition
    directives : Array[Directive]
    selection_set : SelectionSet
    } derive(Eq,
    Debug
    )

    Named fragment definition.

    FragmentDefinition::equal

    FragmentDefinition::not_equal

    FragmentSpread

    pub(all) struct FragmentSpread {
    position : Pos
    fragment_name : String
    directives : Array[Directive]
    } derive(Eq,
    Debug
    )

    Reference to a named fragment.

    FragmentSpread::equal

    FragmentSpread::not_equal

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

    GqlType

    pub(all) enum GqlType {
    NamedType(String)
    ListType(GqlType)
    NonNullType(GqlType)
    } derive(Eq,
    Debug
    )

    GraphQL type reference used by variable, field, and input definitions.

    GqlType::equal

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

    GqlType::not_equal

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

    GqlType::to_repr

    InlineFragment

    pub(all) struct InlineFragment {
    position : Pos
    type_condition : TypeCondition?
    directives : Array[Directive]
    selection_set : SelectionSet
    } derive(Eq,
    Debug
    )

    Inline fragment with optional type condition.

    InlineFragment::equal

    InlineFragment::not_equal

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

    InputObjectType

    pub(all) struct InputObjectType {
    position : Pos
    description : String?
    name : String
    directives : Array[Directive]
    fields : Array[InputValue]
    } derive(Eq,
    Debug
    )

    SDL input object type definition.

    InputObjectType::equal

    InputObjectType::not_equal

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

    InputObjectTypeExtension

    pub(all) struct InputObjectTypeExtension {
    position : Pos
    name : String
    directives : Array[Directive]
    fields : Array[InputValue]
    } derive(Eq,
    Debug
    )

    SDL input object type extension.

    InputObjectTypeExtension::equal

    InputObjectTypeExtension::not_equal

    InputValue

    pub(all) struct InputValue {
    position : Pos
    description : String?
    name : String
    value_type : GqlType
    default_value : Value?
    directives : Array[Directive]
    } derive(Eq,
    Debug
    )

    SDL input field or argument definition.

    InputValue::equal

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

    InputValue::not_equal

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

    InterfaceType

    pub(all) struct InterfaceType {
    position : Pos
    description : String?
    name : String
    implements_interfaces : Array[String]
    directives : Array[Directive]
    fields : Array[SchemaField]
    } derive(Eq,
    Debug
    )

    SDL interface type definition.

    InterfaceType::equal

    InterfaceType::not_equal

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

    InterfaceTypeExtension

    pub(all) struct InterfaceTypeExtension {
    position : Pos
    name : String
    implements_interfaces : Array[String]
    directives : Array[Directive]
    fields : Array[SchemaField]
    } derive(Eq,
    Debug
    )

    SDL interface type extension.

    InterfaceTypeExtension::equal

    InterfaceTypeExtension::not_equal

    Mutation

    pub(all) struct Mutation {
    position : Pos
    name : String?
    variable_definitions : Array[VariableDefinition]
    directives : Array[Directive]
    selection_set : SelectionSet
    } derive(Eq,
    Debug
    )

    Parsed mutation operation.

    Mutation::equal

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

    Mutation::not_equal

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

    Mutation::to_repr

    Number

    pub(all) struct Number {
    value : Int64
    } derive(Eq,
    Debug
    )

    Integer literal wrapper.

    GraphQL integer literals are parsed as Int64 so tooling can preserve the full accepted input range before application-level coercion.

    Number::as_int64

    fn Number::as_int64(self : Number) -> Int64

    Return the parsed integer literal as Int64.

    Number::equal

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

    Number::not_equal

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

    Number::to_repr

    ObjectType

    pub(all) struct ObjectType {
    position : Pos
    description : String?
    name : String
    implements_interfaces : Array[String]
    directives : Array[Directive]
    fields : Array[SchemaField]
    } derive(Eq,
    Debug
    )

    SDL object type definition.

    ObjectType::equal

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

    ObjectType::not_equal

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

    ObjectTypeExtension

    pub(all) struct ObjectTypeExtension {
    position : Pos
    name : String
    implements_interfaces : Array[String]
    directives : Array[Directive]
    fields : Array[SchemaField]
    } derive(Eq,
    Debug
    )

    SDL object type extension.

    ObjectTypeExtension::equal

    ObjectTypeExtension::not_equal

    OperationDefinition

    pub(all) enum OperationDefinition {
    SelectionSetOperation(SelectionSet)
    QueryOperation(Query)
    MutationOperation(Mutation)
    SubscriptionOperation(Subscription)
    } derive(Eq,
    Debug
    )

    GraphQL operation definition, including shorthand selection-set operations.

    OperationDefinition::equal

    OperationDefinition::not_equal

    Pos

    pub(all) struct Pos {
    line : Int
    column : Int
    } derive(Eq,
    Debug
    )

    1-based source position in a GraphQL document.

    Pos::equal

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

    Pos::not_equal

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

    Pos::to_repr

    Query

    pub(all) struct Query {
    position : Pos
    name : String?
    variable_definitions : Array[VariableDefinition]
    directives : Array[Directive]
    selection_set : SelectionSet
    } derive(Eq,
    Debug
    )

    Parsed query operation.

    Query::equal

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

    Query::not_equal

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

    Query::to_repr

    QueryDefinition

    pub(all) enum QueryDefinition {
    OperationDefinition(OperationDefinition)
    FragmentDefinition(FragmentDefinition)
    } derive(Eq,
    Debug
    )

    Top-level executable document definition.

    QueryDefinition::equal

    QueryDefinition::not_equal

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

    QueryDocument

    pub(all) struct QueryDocument {
    definitions : Array[QueryDefinition]
    } derive(Eq,
    Debug
    )

    Parsed executable GraphQL document.

    QueryDocument::equal

    QueryDocument::format

    fn QueryDocument::format(self : QueryDocument, style? : Style) -> String

    Format an executable GraphQL document with a stable canonical layout.

    QueryDocument::not_equal

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

    QueryDocument::output

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

    QueryDocument::to_string

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

    Format an executable GraphQL document using the default style.

    ScalarType

    pub(all) struct ScalarType {
    position : Pos
    description : String?
    name : String
    directives : Array[Directive]
    } derive(Eq,
    Debug
    )

    SDL scalar type definition.

    ScalarType::equal

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

    ScalarType::not_equal

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

    ScalarTypeExtension

    pub(all) struct ScalarTypeExtension {
    position : Pos
    name : String
    directives : Array[Directive]
    } derive(Eq,
    Debug
    )

    SDL scalar type extension.

    ScalarTypeExtension::equal

    ScalarTypeExtension::not_equal

    SchemaDefinition

    pub(all) enum SchemaDefinition {
    SchemaDef(SchemaDefinitionData)
    TypeDef(TypeDefinition)
    TypeExt(TypeExtension)
    DirectiveDef(DirectiveDefinition)
    } derive(Eq,
    Debug
    )

    Top-level SDL definition.

    SchemaDefinition::equal

    SchemaDefinition::not_equal

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

    SchemaDefinitionData

    pub(all) struct SchemaDefinitionData {
    position : Pos
    directives : Array[Directive]
    query : String?
    mutation : String?
    subscription : String?
    } derive(Eq,
    Debug
    )

    Explicit schema { ... } root operation mapping.

    SchemaDefinitionData::equal

    SchemaDefinitionData::not_equal

    SchemaDocument

    pub(all) struct SchemaDocument {
    definitions : Array[SchemaDefinition]
    } derive(Eq,
    Debug
    )

    Parsed GraphQL schema document.

    SchemaDocument::equal

    SchemaDocument::format

    fn SchemaDocument::format(self : SchemaDocument, style? : Style) -> String

    Format an SDL document with a stable canonical layout.

    SchemaDocument::not_equal

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

    SchemaDocument::output

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

    SchemaDocument::to_string

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

    Format an SDL document using the default style.

    SchemaField

    pub(all) struct SchemaField {
    position : Pos
    description : String?
    name : String
    arguments : Array[InputValue]
    field_type : GqlType
    directives : Array[Directive]
    } derive(Eq,
    Debug
    )

    SDL object or interface field definition.

    SchemaField::equal

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

    SchemaField::not_equal

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

    Selection

    pub(all) enum Selection {
    FieldSelection(Field)
    FragmentSpreadSelection(FragmentSpread)
    InlineFragmentSelection(InlineFragment)
    } derive(Eq,
    Debug
    )

    GraphQL field, fragment spread, or inline fragment selection.

    Selection::equal

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

    Selection::not_equal

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

    SelectionSet

    pub(all) struct SelectionSet {
    span : (Pos, Pos)
    items : Array[Selection]
    } derive(Eq,
    Debug
    )

    Non-empty selection set with start and end source positions.

    SelectionSet::equal

    SelectionSet::not_equal

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

    Style

    pub(all) struct Style {
    indent : Int
    multiline_arguments : Bool
    } derive(Eq,
    Debug
    )

    Pretty-printer options for parsed query and schema documents.

    Style::default

    fn Style::default() -> Style

    Default formatting style: two-space indentation and inline arguments.

    Style::equal

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

    Style::not_equal

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

    Style::to_repr

    Style::with_indent

    fn Style::with_indent(self : Style, indent : Int) -> Style

    Return a copy of the style with a new indentation width.

    Style::with_multiline_arguments

    fn Style::with_multiline_arguments(self : Style, multiline_arguments : Bool) -> Style

    Return a copy of the style with multiline argument formatting toggled.

    Subscription

    pub(all) struct Subscription {
    position : Pos
    name : String?
    variable_definitions : Array[VariableDefinition]
    directives : Array[Directive]
    selection_set : SelectionSet
    } derive(Eq,
    Debug
    )

    Parsed subscription operation.

    Subscription::equal

    Subscription::not_equal

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

    Token

    pub(all) struct Token {
    kind : TokenKind
    value : String
    position : Pos
    start_offset : Int
    end_offset : Int
    next_offset : Int
    } derive(Eq,
    Debug
    )

    GraphQL token with source span and the offset after ignored trivia.

    start_offset and end_offset cover the token itself. next_offset points to the next non-ignored source position after whitespace and comments.

    Token::equal

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

    Token::not_equal

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

    Token::to_repr

    TokenKind

    pub(all) enum TokenKind {
    TkPunctuator
    TkName
    TkIntValue
    TkFloatValue
    TkStringValue
    TkBlockString
    TkEof
    } derive(Eq,
    Debug
    )

    Token category emitted by the GraphQL tokenizer.
    impl Show for TokenKind

    TokenKind::equal

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

    TokenKind::not_equal

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

    TokenKind::output

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

    TokenKind::to_string

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

    TypeCondition

    pub(all) enum TypeCondition {
    On(String)
    } derive(Eq,
    Debug
    )

    Fragment type condition.

    TypeCondition::equal

    TypeCondition::not_equal

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

    TypeDefinition

    pub(all) enum TypeDefinition {
    ScalarTypeDef(ScalarType)
    ObjectTypeDef(ObjectType)
    InterfaceTypeDef(InterfaceType)
    UnionTypeDef(UnionType)
    EnumTypeDef(EnumType)
    InputObjectTypeDef(InputObjectType)
    } derive(Eq,
    Debug
    )

    SDL type definition.

    TypeDefinition::equal

    TypeDefinition::not_equal

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

    TypeExtension

    pub(all) enum TypeExtension {
    ScalarTypeExt(ScalarTypeExtension)
    ObjectTypeExt(ObjectTypeExtension)
    InterfaceTypeExt(InterfaceTypeExtension)
    UnionTypeExt(UnionTypeExtension)
    EnumTypeExt(EnumTypeExtension)
    InputObjectTypeExt(InputObjectTypeExtension)
    } derive(Eq,
    Debug
    )

    SDL type extension.

    TypeExtension::equal

    TypeExtension::not_equal

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

    UnionType

    pub(all) struct UnionType {
    position : Pos
    description : String?
    name : String
    directives : Array[Directive]
    types : Array[String]
    } derive(Eq,
    Debug
    )

    SDL union type definition.

    UnionType::equal

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

    UnionType::not_equal

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

    UnionTypeExtension

    pub(all) struct UnionTypeExtension {
    position : Pos
    name : String
    directives : Array[Directive]
    types : Array[String]
    } derive(Eq,
    Debug
    )

    SDL union type extension.

    UnionTypeExtension::equal

    UnionTypeExtension::not_equal

    Value

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

    GraphQL literal or variable value.

    This representation preserves GraphQL-specific distinctions such as enum values versus strings and variables versus their eventual runtime values.

    Value::equal

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

    Value::not_equal

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

    Value::to_repr

    VariableDefinition

    pub(all) struct VariableDefinition {
    position : Pos
    name : String
    var_type : GqlType
    default_value : Value?
    } derive(Eq,
    Debug
    )

    Variable declaration from an operation definition.

    VariableDefinition::equal

    VariableDefinition::not_equal

    consume_definition

    fn consume_definition(source : String) -> (QueryDefinition, String) raise ParseError

    Parse the first executable GraphQL definition and return the unconsumed tail.

    This is useful for stream-like tooling that receives concatenated GraphQL definitions and wants to consume them one at a time.

    minify_query

    fn minify_query(source : String) -> String raise ParseError

    Minify an executable GraphQL document while preserving token boundaries.

    The result removes ignored whitespace and comments, inserting a single space only when two adjacent non-punctuator tokens would otherwise merge.

    parse_query

    fn parse_query(source : String) -> QueryDocument raise ParseError

    Parse a complete executable GraphQL document.

    The document may contain operations and fragment definitions. Empty input and trailing tokens raise ParseError.

    parse_schema

    fn parse_schema(source : String) -> SchemaDocument raise ParseError

    Parse a complete GraphQL SDL document.

    The parser accepts schema definitions, type definitions, type extensions, and directive definitions, preserving descriptions and source positions in the returned AST.

    tokenize

    fn tokenize(source : String) -> Array[Token] raise ParseError

    Tokenize a GraphQL source document.

    The returned array always ends with a TkEof token. Whitespace, commas, and comments are skipped but reflected in token offsets.