/formidadog-ql

A dead simple GraphQL API of dogs @FormidableLabs.

Primary LanguageJavaScriptMIT LicenseMIT

🐶 formidadog-ql 🐶

A dead simple GraphQL API of 🐶 @FormidableLabs. See the demo here.

Build Status Coverage Status Netlify Status

What's This About

Everyone needs a good, simple GraphQL API for making demo apps. Everyone could use more dog photos in their life. And everyone is probably dying to meet the pups of the awesome team at Formidable. To that end, we present formidadog-ql.

Get Me Running!

You know the drill. Clone the repo locally, yarn, yarn start.

git clone https://github.com/parkerziegler/formidadog-ql.git
cd formidadog-ql
yarn
yarn start

This will start the server up at localhost:4000. Go ahead and change the port in src/index.js if you like. We figured you might be using localhost:3000 already 😉.

Note: Running this app locally requires Node >= 8. We make use of async/await for startup, so make sure you're using Node 8 or above. Using LTS is recommended.

What Next?

Once you have the server running, go to localhost:4000/graphql in your browser. You'll get an awesome GraphiQL interface for writing queries, mutations, and exploring the schema.

formidadog-ql-demo

As long as you have the server running, you can hit localhost:4000/graphql from any local app to use this API.

Write a Simple Query

If you're not familiar with the basics of GraphQL, go ahead and check out How to GraphQL for tutorials and an overview. Let's write a simple query to get information on all the dogs at Formidable.

query dogs {
  dogs {
    name
    breed
    description
    imageUrl
    likes
  }
}

To obtain information on a single dog, use the dog query, which accepts a key variable to identify the dog. key is a required ID type in our GraphQL schema.

query dog($key: ID!) {
  dog(key: $key) {
    name
    breed
    likes
  }
}

You can use GraphiQL's variables editor to add the $key variable to the above query.

{
  "key": "VmeRTX7j-"
}

Write a Simple Mutation

To see what mutations are currently available on the API, use the Mutation explorer in GraphiQL. Let's execute a mutation to like one of these pooches!

mutation likeDog($key: ID!) {
  likeDog(key: $key) {
    name
    likes
  }
}

Each time we execute this mutation, we should see the mutated dog's likes increment by one.

How You Can Help

This API is not fully formed yet. There's plenty of great queries, mutations, and subscriptions left to be added. Go ahead and open a PR! If you find a bug, please file an issue.