sibyl229 / wb-graphql

2 stars 0 forks source link

The GraphQL API and IDE for WormBase data in Datomic database.

Try it live at http://52.90.214.72:4003/

Get started

Sample queries

Here are some example query:

query {
  gene(id: "WBGene00000426") {
    public_name
    gene__OF__interaction__VIA__interactor_overlapping_gene {
      interactor_overlapping_gene__OF__interaction {
        id
        interactor_overlapping_gene {
          gene {
            public_name
          }
        }
      }
    }
  }
}

Sample mutations

N/A at the moment

Overview

This is a web tool I made for exploring data in our Datomic database, and fetching just the fields you need on any entity/object. All of these through the website or its web API. This tool implements the GraphQL API standard, which is designed for ease of data exchange over the web.

So far, I made this tool to work with two types of queries (or access point), one is to get a list of genes based on a list of gene names, the other is to get any entity by its WormBase ID. Within each query, you will specify which fields you like to fetch, and you will get results that mirror the shape of the query.

FAQ and tips

Use wb-graphql as a library

wb-graphql provides ring handlers that can be combined with a ring web service.

Include the following in the your project.clj dependencies:

[wormbase/wb-graphql "0.1.0"]
[com.datomic/datomic-pro "0.9.5554" :exclusions [joda-time]]
[com.amazonaws/aws-java-sdk-dynamodb "1.11.6" :exclusions [joda-time]]

Create a ring handler with wb-graphql

(ns rest-api.routing
  (:require
   [datomic.api :as d]
   [wb-graphql.handler]))

(def db (d/db datomic-conn))

(defn graphql-routes [request]
  (let [handler (-> (wb-graphql.handler/create-routes)
                    (wb-graphql.handler/wrap-app db))]
    (handler request)))

Run wb-graphql as a standalone web service

Locate the standlone uberjar, or refer here to build a standalone uberjar.

java -jar path/to/standalone-uberjar.jar

Or with appropriate environment variable

PORT=[Your_Port] WB_DB_URI=[Your_Datomic_URI] java -jar path/to/standalone-uberjar.jar

To contribute

Obtain credentials

TODO...

Prepare environment

npm install

npm run build

Start server

lein ring server-headless [YOUR_PORT_NO]

Access graphiql from

http://localhost:[YOUR_PORT_NO]

Build jar

to use as a library

npm run build    # build static resources
lein run    # build graphql schema
lein jar    # build jar
lein deploy tmp   # deploy to local repository for testing

Build standalone uberjar

to run as a server

npm run build    # build static resources
lein run    # build graphql schema
lein ring uberjar    # build standalone uberjar

Acknowledgement

This project was bootstrapped with GraphQL starter project for Clojure, which uses graphql-clj, GraphiQL, and Create React App.