robvandenbogaard / elm-terminusdb / TerminusDb.Woql

Construct WOQL requests and read out responses using this module.


type Request
    = QueryRequest (List TerminusDb.Schema.Prefix.Prefix) Query
    | QueryCommitRequest (List TerminusDb.Schema.Prefix.Prefix) Query CommitInfo

Represents a WOQL request with or without provided commit metadata.

request : Request -> Json.Encode.Value

Encodes a WOQL request with provided query.


type alias CommitInfo =
{ author : String
, message : String 
}

Represents meta information sent with a commit.

commitInfo : CommitInfo -> Json.Encode.Value

CommitInfo encoder.


type alias Response =
{ success : Basics.Bool
, variables : List String
, bindings : Bindings
, inserts : Basics.Int
, deletes : Basics.Int
, retries : Basics.Int 
}

Represents a WOQL response record.

response : TerminusDb.Schema.Prefix.Context -> Json.Decode.Decoder Response

WOQL Response decoder.

success : TerminusDb.Schema.Prefix.Context -> Json.Decode.Decoder Basics.Bool

Decoder for determining whether a response was successful.


type Error
    = BadConnection String
    | BadResponse Basics.Int String
    | BadData String

Represents the types of errors that can occur in WOQL requests.


type alias Bindings =
List (Dict String String)

Represents bindings of names (dict keys) to query variables (dict values).


type Query
    = Select Variables Query
    | And (List Query)
    | Or (List Query)
    | Triple Subject Predicate Object
    | Optional Query
    | Limit Basics.Int Query
    | AddTriple Subject Predicate Object
    | AddQuad Subject Predicate Object Graph
    | IdGen Base Key String

Represents the WOQL query language.


type alias Subject =
Value

Represents the Subject within a triple.


type alias Predicate =
Value

Represents the Predicate within a triple.


type alias Object =
Value

Represents the Object within a triple.


type alias Graph =
Value

Represents the Graph within a quad (triple + graph).


type Value
    = Var String
    | Node TerminusDb.Schema.Prefix.Prefix String
    | Literal String
    | Datatype TerminusDb.Schema.TranslatedText

Represents a WOQL query value, a variable, node reference, literal, or translated data type.


type alias Variables =
List String

Represents a list of WOQL variable names.

expectJson : (Result Error a -> msg) -> Json.Decode.Decoder a -> Http.Expect msg

Helper for building WOQL response expectations and adding error categories for easy handling in applications.