GraphQL starter project for Clojure with graphql-clj and GraphiQL
Switch branches/tags
Nothing to show
Clone or download
Pull request Compare This branch is 5 commits ahead, 2 commits behind tendant:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
build
public
src
.gitignore
README.md
package.json
project.clj
yarn.lock

README.md

This project is a Demo project for graphql-clj and GraphiQL. You can start trying Clojure with GraphQL in a few minutes.

This project was bootstrapped with Create React App.

Start server

lein ring server-headless

Access graphiql from

http://localhost:3002/index.html

Sample queries

query {
  human (id:"1002") {
    id
    name
    friends {
      id
      name
      friends {
        id
      }
    }
  }
}

To get all characters, try searching without an ID:

query {
  characters {
    name
    friends {
      name
    }
  }
}

Specifically, Humans and Droids are both arrays as a return type, although they support passing an individual ID:

query {
  human(id: "1001") {
    name
  }
  
  droid(id: "2000") {
    name
  }
}

If you want to select more than one ID, then pass an array of IDs to the humans query type.

query Q($list: [String!]){
  humans(ids: $list){
    name
  }
}

Try these example variables:

{
  "list": ["1001", "1002", "1003"]
}

The same is possible with the droids type.

query Q($list: [String!]){
  droids(ids: $list){
    name
    primaryFunction
  }
}

Valid IDs for droids to test variables are "2000" and "2001".

Sample mutations

mutation{
  createHuman (name:"testname", friends:[]) {
    id
  }
}

Build Application (HTML & JS)

Note: Not required, unless you want to make changes to Javascript code

npm install

npm run build