EQL and Pathom

WORK IN PROGRESS

EQL - EDN Query Language

  • a graph query language based on attributes
  • inspired by Datomic pull syntax
  • focus on data retrieval
  • prominently used in Fulcro
  • popular query engine: Pathom

Representing data as graph

Sample Graph

EQL Basics

Query result is a nested map of attributes. To specify which attributes to include, use a vector

EQL

Result

[:account/id :account/name]
{:account/id "0000"
 :account/name "Raygen"
}

EQL Basics

How to go deeper?

Replace attribute with a map with a single entry:
attr -> sub-query

EQL

Result

[:account/id :account/name 
 {:account/owner [:user/name :user/email]}]
{:account/id "0000"
 :account/name "Raygen"
 :account/owner {:user/name "Han Solo" 
                 :user/email "han@solo.net"}
}

EQL Basics

But which account am I querying?
Use an ident to identify a starting point:

[attr some-data]

EQL

Result

[[:account/id "0000"]]
{[:account/id "0000"] #:account{:id "0000"}}

EQL Basics

Combine with sub-query syntax

EQL

Result

[{[:account/id "0000"] [:account/name]}]
{[:account/id "0000"] #:account{:name "Raygen Key"}}

EQL Basics

What about conditions, paging, searching?

Add parameters to any attributes with (attr param)

Up to resolvers what is available

 

EQL

Result

[{(:account/all 
   {:search-term "Raygen"
     :sort-key    [:account/address :address/street1]
     :limit       5
     :offset      5}) [:account/name]}]
#:account{:all [#:account{:name "Raygen Key"}
                #:account{:name "Raygen Level Key"}
                #:account{:name "Raygen Level"}
                #:account{:name "Raygen Steiner"}
                #:account{:name "Raygen Home"}]}

EQL and Pathom

By Jochen Bedersdorfer

EQL and Pathom

  • 515