GraphQLZero

Fake Online GraphQL API for Testing and Prototyping

Zero-Config, No Registration, Compatible with React, Angular, Vue, and more

Powered by JSONPlaceholder and Apollo

Intro

GraphQLZero is a free, online GraphQL API that you can use to get fake data from a real backend while testing or prototyping your app. It is inspired and powered by JSONPlaceholder, serving the same dataset but in the form of a GraphQL server. You'll find it useful for learning more about GraphQL, writing tutorials, testing new libraries, and more.

Examples

Below you can try out a few example queries and mutations for common use cases like getting a list of resources, retrieving a specific entity, or exploring nested relationships.

For more details about the different entities, check out the Schema.

Get Started

The easiest way to get started is by visiting the GraphQL API Playground. There, you can see the API's docs and run queries against the real backend. Feel free to copy one of the queries in the examples above to get you started.

Playground Query

1) GraphQL Playground: Query Execution.

Playground Docs

2) GraphQL Playground: API Docs.

To use GraphQLZero from your app, a simple POST request using fetch will do the job. You can try out the following code right from your browser's console.

fetch("https://graphqlzero.almansi.me/api", {
  "method": "POST",
  "headers": { "content-type": "application/json" },
  "body": JSON.stringify({
    query: `{
      user(id: 1) {
        id
        name
      }
    }`
  })
}).then(res => res.json()).then(console.log)
// { "data": { "user": { ... } } }

A GraphQL client will be necessary for anything beyond the basics. For example, if you're using JavaScript, Apollo Client can come in handy. The following code will get your client set up and issue a simple query.

import ApolloClient, { gql } from 'apollo-boost';

const client = new ApolloClient({
  uri: 'https://graphqlzero.almansi.me/api'
});
client.query({ query: gql`
  {
    user(id: 1) {
      id
      name
    }
  }
`}).then(console.log);
// { "data": { "user": { ... } } }

Schema

GraphQLZero is powered by JSONPlaceholder and serves the same dataset in the form of a GraphQL API. Six different types of entities exist: users, posts, comments, todos, albums, and photos. These entities are also related to each other; for example, a user has many posts, a photo belongs to an album, etc.

For more information on how to query different entities, check out the examples or dive into the full schema in the GraphQL API Playground.