This repo contains an example of using GraphQL with CouchDB, for the purposes of testing next generation data fetching within our apps, especially ESDB.
- Install CouchDB. It is a simple install for the mac. Once installed start it up.
- Start Futon, the GUI front end of CouchDB. This is done by navigating to: http://127.0.0.1:5984/_utils/index.html
- Make an "esdb" database within Futon
- Install babel-node
npm install --global babel
- Run the input script to import some contacts from ESDB into CouchDB
babel-node import.js
. Check the data in Futon to see if it imported correctly. - Upload our database views:
curl -X PUT http://127.0.0.1:5984/esdb/_design/esdb --data-binary @couchdb/design.json
NOTE: If you want to update the views, you will need to add a_rev
property to the couchdb/design.json file to specify the current version. You can find the current version in Futon.
Now that the database is setup, run the GraphQL server by running:
babel-node index.js
Then navigate to the GraphiQL web client at: http://localhost:8080/graphql
query ESDB {
contact(id: "contact-982") {
id
first_name
last_name
location {
short_name
full_name
}
}
}