catchpocket is a tool to automatically generate lacinia schema information from a datomic database. The schemas it generates work with the stillsuit library at runtime to resolve GraphQL queries against the database.
catchpocket is in alpha and it is possible the API and config formats will change.
catchpocket depends on the datomic libraries being installed locally. To do so:
- Download datomic from my.datomic.com
- Unzip it somewhere
- From the root of that folder, run
bin/maven-installto install the client libraries in your local repository.
See also the instructions at datomic.com.
You can run catchpocket from leiningen (via lein run) or from the Clojure
command-line tools from tools.deps.alpha
(via clojure -m catchpocket.main).
Catchpocket takes the path to an EDN configuration file as its main parameter.
clojure -m catchpocket.main ./doc/samples/mbrainz.edn
The configuration file specifies what database to connect to, and what file
to produce as output; see
the files in doc/sample
for some examples.
See the stillsuit-sample
project for some instructions on quickly setting up graphiql for a datomic
database.
Documentation is still pretty sparse, sorry, but we want to improve it. Once it's ready, the user manual will be online here.
See also these slides for a brief talk about stillsuit and catchpocket.
catchpocket inspects a datomic database and gets metadata about its attributes;
it then inspects its data to do a bit of inference about how to map entity data
to lacinia schema information. It then generates a lacinia schema configuration.
At runtime, the schema can be used with the stillsuit library to execute
queries against the database.
catchpocket works by making a bunch of assumptions about the way your data is set up that may not be true (and are conventions datomic doesn't enforce):
- It assumes that every entity has a distinct namespace, so that a
:userentity has:user/idand:user/nameattributes, but not an:address/postal-codeattribute. - It assumes that attribute refs always point to the same type of entity.
These assumptions are probably incorrect for many datomic databases. You can configure catchpocket's operation via the config file to ameliorate some of the resulting problems.
catchpocket reads its configuration from two primary sources.
- A config file (in EDN)
- Optionally, metadata in the datomic database itself can be attached to attributes to tell catchpocket what sort of lacinia schema to generate from them.
When it's finished, catchpocket generates an EDN file which can then be used as a lacinia schema.
Because many datomic primitives are not directly supported in GraphQL, catchpocket currently assumes that you will use the stillsuit library in conjunction with the generated schema in order to provide some default resolvers for references and other datomic types.
The umlaut project works off of a graphql schema as its primary input, and is then capable of generating a datomic schema from the schema, along with specs, graphviz diagrams, and a bunch of other cool stuff. Where catchpocket is database-first, umlaut is document-first.
In Frank Herbert's Dune novels, a catchpocket is a place where precious water is stored.
Licensed under Apache 2.0 license, see LICENSE. Copyright (c) 2018 Workframe.
- Security / predicates on attributes
- Inference
- Inject session (/logged-in user) API
- Attach stillsuit and run queries
- Handle empty enum scans correctly (currently breaks lacinia spec)