Code Monkey home page Code Monkey logo

fakerql's Introduction

FakerQL

FakerQL was created for frontend developers and GraphQL powered apps. Whether you're getting started with a new project or learning Relay/Apollo, you can forget about building a custom server and rely on Faker.js to provide some goodies!

Give it a try

You can head over to GraphiQL to send some example queries and mutations.

Queries

Get authorised user

You can request the logged in user provided you pass a valid Authorization header with a signed JWT. This can be done using the register/login mutations.

# me

{
  me {
    id
    firstName
    lastName
    email
    avatar
  }
}

Get a list of users

You can request a list of users. count is optional and defaults to 25.

# allUsers(count: Int)

{
  allUsers(count: 5) {
    id
    firstName
    lastName
    email
    avatar
  }
}

Get a User

You can request a single User by providing any ID.

# User(id: String!)

{
  allUsers(id: "wk0z1j1tzj7xc0116is3ckdrx") {
    id
    firstName
    lastName
    email
    avatar
  }
}

Get a list of products

You can request a list of products. count is optional and defaults to 25.

# allProducts(count: Int)

{
  allProducts(count: 5) {
    id
    name
    price
  }
}

Get a Product

You can request a single Product by providing any ID.

# Product(id: String!)

{
  allProduct(id: "cjbrygtdz3e480147hv8ozt40") {
    id
    name
    price
  }
}

Get a list of todos

You can request a list of todos. count is optional and defaults to 25.

# allTodos(count: Int)

{
  allTodos(count: 5) {
    id
    title
    completed
  }
}

Get a Todo

You can request a single Todo by providing any ID.

# Todo(id: String!)

{
  Todo(id: "cjbrygq0u3e4301476mfqoaae") {
    id
    title
    completed
  }
}

Get a list of posts

You can request a list of posts. count is optional and defaults to 25.

# allPosts(count: Int)

{
  allPosts(count: 5) {
    id
    title
    body
    published
    createdAt
    author {
      id
      firstName
      lastName
      avatar
    }
  }
}

Get a Post

You can request a single Post by providing any ID.

# Post(id: String!)

{
  Post(id: "cjbryfb1x3e3c0147f4f4110o") {
    id
    title
    body
    published
    createdAt
    author {
      id
      firstName
      lastName
      avatar
    }
  }
}

Mutations

Register user

Registering a User returns a random signed JWT. expiresIn is optional and pretty much pointless right now.

# register(email: String!, password: String!, expiresIn: String)

mutation {
  register(email: "[email protected]", password: "F4K3rqL!", expiresIn: '24h') {
    token
  }
}

Login user

Logging in a User returns a random signed JWT. expiresIn is optional and pretty much pointless right now.

# login(email: String!, password: String!, expiresIn: String)

mutation {
  login(email: "[email protected]", password: "F4K3rqL!") {
    token
  }
}

Updating user

This mutation returns the updated data you passed in to update.

# updateUser(id: ID!, email: String!, firstName: String, lastName: String)

mutation {
  updateUser(id: "wk0z1j1tzj7xc0116is3ckdrx", firstName: "Jim") {
    id
    firstName
    lastName
  }
}

➡️ You must specify the header Authorization: Bearer token to satisfy this mutation.

Create Todo

This mutation returns the data you sent arguments + a fake ID.

# createTodo(title: String!, completed: Boolean)

mutation {
  createTodo(title: "Book movie tickets") {
    id
    title
    completed
  }
}

Subscriptions

Coming soon.

Client side library example

The example below uses graphql-request.

import { request } from 'graphql-request';

const query = `{
  products: allProducts(count: 25) {
    id
    name
    price
  }

  user: User(id: "wk0z1j1tzj7xc0116is3ckdrx") {
    id
    firstName
    lastName
    email
    avatar
  }
}`;

request('https://fakerql.com/graphql', query).then(data => console.log(data));

Todo

  • Subscriptions
  • Custom directives

fakerql's People

Contributors

notrab avatar renovate-bot avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.