GraphQL API Documentation
schema {
query: Query
mutation: Mutation
}
type Query {
posts: [Post!]!
post(id: ID!): Post
search(keyword: String!): [SearchResult!]!
users: [User!]!
}
type Mutation {
addPost(input: NewPostInput!): Post!
registerUser(input: NewUserInput!): User!
}
type Post implements Node {
id: ID!
title: String!
content: String!
status: PostStatus!
author: User!
}
type User implements Node {
id: ID!
name: String!
role: UserRole!
posts: [Post!]!
}
interface Node {
id: ID!
}
PostStatus
enum PostStatus {
DRAFT
PUBLISHED
ARCHIVED
}
UserRole
enum UserRole {
ADMIN
EDITOR
READER
}
union SearchResult = Post | User
NewPostInput
input NewPostInput {
title: String!
content: String!
authorId: ID!
}
input NewUserInput {
name: String!
role: UserRole!
}