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!
You can head over to GraphiQL to send some example queries and mutations.
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
}
}
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
}
}
You can request a single User by providing any ID.
# User(id: String!)
{
allUsers(id: "wk0z1j1tzj7xc0116is3ckdrx") {
id
firstName
lastName
email
avatar
}
}
You can request a list of products. count
is optional and defaults to 25.
# allProducts(count: Int)
{
allProducts(count: 5) {
id
name
price
}
}
You can request a single Product by providing any ID.
# Product(id: String!)
{
allProduct(id: "cjbrygtdz3e480147hv8ozt40") {
id
name
price
}
}
You can request a list of todos. count
is optional and defaults to 25.
# allTodos(count: Int)
{
allTodos(count: 5) {
id
title
completed
}
}
You can request a single Todo by providing any ID.
# Todo(id: String!)
{
Todo(id: "cjbrygq0u3e4301476mfqoaae") {
id
title
completed
}
}
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
}
}
}
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
}
}
}
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: "hi@jamiebarton.co.uk", password: "F4K3rqL!", expiresIn: '24h') {
token
}
}
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: "hi@jamiebarton.co.uk", password: "F4K3rqL!") {
token
}
}
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.
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
}
}
Coming soon.
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));
- Subscriptions
- Custom directives