https://github.com/jcelliott/unicorn
Example GraphQL API with Absinthe
https://github.com/jcelliott/unicorn
absinthe elixir graphql
Last synced: 3 months ago
JSON representation
Example GraphQL API with Absinthe
- Host: GitHub
- URL: https://github.com/jcelliott/unicorn
- Owner: jcelliott
- Created: 2018-08-04T05:02:17.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-08-07T15:21:49.000Z (about 7 years ago)
- Last Synced: 2025-04-12T14:51:46.704Z (6 months ago)
- Topics: absinthe, elixir, graphql
- Language: Elixir
- Homepage:
- Size: 110 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Unicorn
To start your Phoenix server:
* Install dependencies with `mix deps.get`
* Create and migrate your database with `mix ecto.create && mix ecto.migrate`
* Install Node.js dependencies with `cd assets && npm install`
* Start Phoenix endpoint with `mix phx.server`Now you can visit [`localhost:4000`](http://localhost:4000) from your browser.
Ready to run in production? Please [check our deployment guides](http://www.phoenixframework.org/docs/deployment).
## Learn more
* Official website: http://www.phoenixframework.org/
* Guides: http://phoenixframework.org/docs/overview
* Docs: https://hexdocs.pm/phoenix
* Mailing list: http://groups.google.com/group/phoenix-talk
* Source: https://github.com/phoenixframework/phoenix# Example queries:
### Get top three users
```graphql
query {
users(sortBy: "money", limit: 3) {
id
username
money
revenueRate
}
}
```### Create a new user
```graphql
mutation {
createUser(username: "somebody") {
user {
username
id
}
}
}
```### Add "auth" in header:
{"CurrentUserId": "cced5bf9-a2cf-49a3-9278-ffce7a7db27a"}
### Get the current user
```graphql
query {
viewer {
username
money
revenueRate
expenseRate
}
}
```### List available purchases
```graphql
query {
purchases {
type
name
cost
codeRate
revenueRate
expenseRate
}
}
```### Hire an employee
```graphql
mutation {
purchase(purchase: {type: "employee", name: "dev_intern"}) {
user {
username
employees {
hacker
}
}
}
}
```### Release your product on the world
```graphql
mutation {
release {
user {
username
revenueRate
money
}
}
}
```