swell/parser

Types

Argument (name: value)

pub type Argument {
  Argument(name: String, value: ArgumentValue)
}

Constructors

Argument value types

pub type ArgumentValue {
  IntValue(String)
  FloatValue(String)
  StringValue(String)
  BooleanValue(Bool)
  NullValue
  EnumValue(String)
  ListValue(List(ArgumentValue))
  ObjectValue(List(#(String, ArgumentValue)))
  VariableValue(String)
}

Constructors

  • IntValue(String)
  • FloatValue(String)
  • StringValue(String)
  • BooleanValue(Bool)
  • NullValue
  • EnumValue(String)
  • ListValue(List(ArgumentValue))
  • ObjectValue(List(#(String, ArgumentValue)))
  • VariableValue(String)

GraphQL Document (top-level)

pub type Document {
  Document(operations: List(Operation))
}

Constructors

GraphQL Operation

pub type Operation {
  Query(SelectionSet)
  NamedQuery(
    name: String,
    variables: List(Variable),
    selections: SelectionSet,
  )
  Mutation(SelectionSet)
  NamedMutation(
    name: String,
    variables: List(Variable),
    selections: SelectionSet,
  )
  Subscription(SelectionSet)
  NamedSubscription(
    name: String,
    variables: List(Variable),
    selections: SelectionSet,
  )
  FragmentDefinition(
    name: String,
    type_condition: String,
    selections: SelectionSet,
  )
}

Constructors

pub type ParseError {
  UnexpectedToken(lexer.Token, String)
  UnexpectedEndOfInput(String)
  LexerError(lexer.LexerError)
}

Constructors

Selection (field or fragment)

pub type Selection {
  Field(
    name: String,
    alias: option.Option(String),
    arguments: List(Argument),
    selections: List(Selection),
  )
  FragmentSpread(name: String)
  InlineFragment(
    type_condition: option.Option(String),
    selections: List(Selection),
  )
}

Constructors

Selection Set (list of fields)

pub type SelectionSet {
  SelectionSet(selections: List(Selection))
}

Constructors

Variable definition

pub type Variable {
  Variable(name: String, type_: String)
}

Constructors

  • Variable(name: String, type_: String)

Values

pub fn parse(source: String) -> Result(Document, ParseError)

Parse a GraphQL query string into a Document

Search Document