• Stars
    star
    142
  • Rank 258,495 (Top 6 %)
  • Language
    Clojure
  • License
    MIT License
  • Created almost 9 years ago
  • Updated almost 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Powerful Data Access for Clojure

claro

Documentation | Guides

claro is a library that allows you to streamline your data access, providing powerful optimisations and abstractions along the way.

Build Status Clojars Artifact codecov

It is inspired by muse and heavily influenced by GraphQL.

claro requires Clojure ≥ 1.7.0.

Features

claro is designed to be flexible and extensible. It'll make your data access more elegant, efficient and testable, providing things like:

  • batched resolution of similar entities,
  • automatic caching of already known resolution results,
  • engine middlewares to hook into the resolution logic, allowing e.g. generic cache or circuit breaker implementations,
  • pluggable resolution strategies in the form of Resolvable selectors,
  • an exchangeable deferred implementation, defaulting to manifold,
  • and pre-built middlewares for data source mocking, introspection and result transformation.

Quickstart

Data access is defined within records implementing the Resolvable interface. Note that they can always produce more resolvables:

(require '[claro.data :as data]
         '[manifold.deferred :as d])

(defrecord Person [id]
  data/Resolvable
  (resolve! [_ env]
    (d/future
      (fetch-person! (:db env) id)))
  data/Transform
  (transform [_ {:keys [friend-ids] :as person}]
    (assoc person :friends (map #(Person. %) friend-ids))))

Blindly resolving an infinite tree like this is usually not a good idea – but claro offers tree projections you can use to describe abstract transformations of infinite structures:

(require '[claro.projection :as projection])

(def person-with-friend-names
  {:id      projection/leaf
   :name    projection/leaf
   :friends [(projection/extract :name)]})

And here we go:

(require '[claro.engine :as engine])

(engine/run!!
  (-> (->Person 1)
      (projection/apply person-with-friend-names)))
;; => {:id 1, :name "Sherlock Holmes", :friends ["Dr. Watson", "Ms. Hudson"]}

Related Projects

Library Description
alumbra GraphQL implementation on top of claro
claro.circuit-breaker Circuit-breaker middleware based on resilience4j

Feel free to open a pull request to add your project to this table.

Documentation

  1. Basic Resolution
  2. Projections
  3. Advanced Projections
  4. Engine
  5. Testing & Debugging
  6. Implementation Notes

All these topics are also available in claro's auto-generated documentation.

Contributing

Contributions are always welcome. Please take a look at the Contribution Guidelines for a quick overview of how your changes can best make it to master.

License

MIT License

Copyright (c) 2015-2017 Yannick Scherer

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

More Repositories

1

lein-ancient

Check your Projects for outdated Dependencies
Clojure
561
star
2

pandect

Fast and easy-to-use Message Digest, Checksum and HMAC library for Clojure
Clojure
221
star
3

bashing

Smashing Bash into Pieces
Shell
79
star
4

thrift-clj

Thrift and Clojure!
Clojure
65
star
5

peripheral

Component & System Creation for Stuart Sierra's Component Library
Clojure
50
star
6

version-clj

Version Number Analysis and Comparison for Clojure(Script)
Clojure
42
star
7

nginx-sidecar-basic-auth

Docker image for an nginx proxy providing HTTP basic auth
Smarty
30
star
8

lexington

[DEPRECATED] A Clojure Lexer (and possibly Parser) Generator
Clojure
29
star
9

invariant

Invariants on Clojure Data Structures
Clojure
26
star
10

jansi-clj

Clojure Wrapper around Jansi (Terminal Colors, Cursor Movement, ...), even for Windows.
Clojure
26
star
11

lein-thriftc

Leiningen Plugin for Apache Thrift
Clojure
25
star
12

codox-theme-rdash

A Modern Look for your Clojure Documentation
CSS
24
star
13

base64-clj

Fast Base64 Encoding/Decoding for Clojure
Clojure
23
star
14

kithara

A Clojure Library for Reliable RabbitMQ Consumers
Clojure
21
star
15

lein-license

Project-Level License Management
Clojure
20
star
16

microbe-vim

A Pathogen-based Vim Plugin Manager for GitHub Repositories
Shell
19
star
17

ronda-schema

HTTP Request/Response Schemas for Clojure + Ring
Clojure
13
star
18

ancient-clj

Version Metadata Retrieval for Maven Artifacts
Clojure
13
star
19

ronda-routing

Middleware-based Routing and Routing-based Middlewares for Clojure + Ring
Clojure
12
star
20

cpath-clj

Collect Files in Classpath Directories
Clojure
10
star
21

minion

Clojure '-main' helper
Clojure
8
star
22

ritual

[DEPRECATED] Database Fixtures for Clojure
Clojure
6
star
23

panoptic

[DEPRECATED] Monitor your Files and Directories for Changes!
Clojure
5
star
24

haxlike

A Java experiment on declarative data fetching
Java
5
star
25

lein-isolate

Dependency Isolation for Leiningen Plugins
Clojure
4
star
26

combit

A Clojure DSL for manipulating fixed-size Containers (e.g. Blocks of Bits)
Clojure
4
star
27

stateful

Stateful Generators for Clojure's test.check
Clojure
4
star
28

claro.circuit-breaker

Circuit-breaker Middleware for Claro Engines
Clojure
3
star
29

thrift-clj-example

Examples for thrift-clj.
Clojure
3
star
30

.dotfiles

config & dots
Shell
2
star
31

clojure-propaganda

A series of annotated Clojure files for showcasing language features
Clojure
1
star
32

fd-multiplex

Multiplexing over C file descriptors. [just an exercise]
C
1
star
33

warsjawa

Code for "Clojure WebApps" at Warsjawa 2014
Clojure
1
star
34

asset-builder

Utility for ClojureScript/JS/CSS Building and Minification
Clojure
1
star
35

midje-teamcity

Midje Emitter for TeamCity
Clojure
1
star
36

lein-testem

Gotta test'em all.
Clojure
1
star
37

graphql-clj-bench

Benchmarks for 'tendant/graphql-clj'
Clojure
1
star
38

yesql-sugar

syntactic sugar for yesql
Clojure
1
star
39

alfred-workflows-nix

Nix
1
star