Simple express server that implements CRUD operations on a graphQL endpoint. A non-persistent JSON database is used for mock data.
App is live on Heroku.
git clone https://github.com/vikvikvr/graphql-crud.git
cd graphql-crud
npm install
npm start
Now open the browser and visit http://localhost:5000/graphql
to start interacting with GraphiQL.
type User {
id: ID
firstname: String
lastname: String
username: String
posts: [Post]
}
type Post {
id: ID
title: String
content: String
author: User
}
type Query {
users: [User]
user(id: ID): User
posts: [Post]
post(id: ID): Post
}
type Mutation {
addUser(input: UserInput): User
addPost(input: PostInput): Post
updateUser(input: UserInput, id: ID): User
updatePost(input: PostInput, id: ID): Post
deleteUser(id: ID): [User]
deletePost(id: ID): [Post]
}
Use the docs
on the top right of the graphiQL interface to get help while trying these out.