Skip to content

Latest commit

 

History

History
405 lines (330 loc) · 9.5 KB

GRAPHQL_API_SPEC.md

File metadata and controls

405 lines (330 loc) · 9.5 KB

RealWorld GraphQL API Spec

Authentication Header:

Authorization: Token jwt.token.here

GraphQL Schema:

GraphQL Schema graph generated with GraphQL Voyager: GraphQL Schema graph

GraphiQL Explorer | Documentation

This schema can be used with different graphql clients: Relay, Apollo, etc.

# Autogenerated input type of AddComment
input AddCommentInput {
  articleId: ID!
  body: String!

  # A unique identifier for the client performing the mutation.
  clientMutationId: String
}

# Autogenerated return type of AddComment
type AddCommentPayload {
  # A unique identifier for the client performing the mutation.
  clientMutationId: String
  comment: Comment
  errors: [UserError!]!
}

type Article {
  author: User
  body: String!
  comments: [Comment!]!
  createdAt: ISO8601DateTime!
  description: String!
  favoritesCount: Int!
  id: ID!
  slug: String!
  tagList: [String!]!
  title: String!
  updatedAt: ISO8601DateTime!
  viewerHasFavorited: Boolean!
}

# The connection type for Article.
type ArticleConnection {
  # A list of edges.
  edges: [ArticleEdge]

  # Information to aid in pagination.
  pageInfo: PageInfo!
}

# An edge in a connection.
type ArticleEdge {
  # A cursor for use in pagination.
  cursor: String!

  # The item at the end of the edge.
  node: Article
}

type Comment {
  article: Article
  author: User
  body: String!
  createdAt: ISO8601DateTime!
  id: ID!
  updatedAt: ISO8601DateTime!
}

# Autogenerated input type of CreateArticle
input CreateArticleInput {
  body: String!

  # A unique identifier for the client performing the mutation.
  clientMutationId: String
  description: String!
  tagList: [String!]!
  title: String!
}

# Autogenerated return type of CreateArticle
type CreateArticlePayload {
  article: Article

  # A unique identifier for the client performing the mutation.
  clientMutationId: String
  errors: [UserError!]!
}

# Autogenerated input type of CreateUser
input CreateUserInput {
  # A unique identifier for the client performing the mutation.
  clientMutationId: String
  email: String!
  password: String!
  username: String!
}

# Autogenerated return type of CreateUser
type CreateUserPayload {
  # A unique identifier for the client performing the mutation.
  clientMutationId: String
  errors: [UserError!]!
  user: User
}

# Autogenerated input type of DeleteArticle
input DeleteArticleInput {
  # A unique identifier for the client performing the mutation.
  clientMutationId: String
  id: ID!
}

# Autogenerated return type of DeleteArticle
type DeleteArticlePayload {
  article: Article!

  # A unique identifier for the client performing the mutation.
  clientMutationId: String
}

# Autogenerated input type of DeleteComment
input DeleteCommentInput {
  # A unique identifier for the client performing the mutation.
  clientMutationId: String
  id: ID!
}

# Autogenerated return type of DeleteComment
type DeleteCommentPayload {
  # A unique identifier for the client performing the mutation.
  clientMutationId: String
  comment: Comment
}

# Autogenerated input type of FavoriteArticle
input FavoriteArticleInput {
  # A unique identifier for the client performing the mutation.
  clientMutationId: String
  id: ID!
}

# Autogenerated return type of FavoriteArticle
type FavoriteArticlePayload {
  article: Article

  # A unique identifier for the client performing the mutation.
  clientMutationId: String
}

# Autogenerated input type of FollowUser
input FollowUserInput {
  # A unique identifier for the client performing the mutation.
  clientMutationId: String
  id: ID!
}

# Autogenerated return type of FollowUser
type FollowUserPayload {
  # A unique identifier for the client performing the mutation.
  clientMutationId: String
  user: User
}

# The connection type for User.
type FollowersConnection {
  # A list of edges.
  edges: [UserEdge]

  # A list of nodes.
  nodes: [User]

  # Information to aid in pagination.
  pageInfo: PageInfo!
  totalCount: Int!
}

# An ISO 8601-encoded datetime
scalar ISO8601DateTime

type Mutation {
  addComment(input: AddCommentInput!): AddCommentPayload
  createArticle(input: CreateArticleInput!): CreateArticlePayload
  createUser(input: CreateUserInput!): CreateUserPayload
  deleteArticle(input: DeleteArticleInput!): DeleteArticlePayload
  deleteComment(input: DeleteCommentInput!): DeleteCommentPayload
  favoriteArticle(input: FavoriteArticleInput!): FavoriteArticlePayload
  followUser(input: FollowUserInput!): FollowUserPayload
  signInUser(input: SignInUserInput!): SignInUserPayload
  unfavoriteArticle(input: UnfavoriteArticleInput!): UnfavoriteArticlePayload
  unfollowUser(input: UnfollowUserInput!): UnfollowUserPayload
  updateArticle(input: UpdateArticleInput!): UpdateArticlePayload
  updateUser(input: UpdateUserInput!): UpdateUserPayload
}

# Information about pagination in a connection.
type PageInfo {
  # When paginating forwards, the cursor to continue.
  endCursor: String

  # When paginating forwards, are there more items?
  hasNextPage: Boolean!

  # When paginating backwards, are there more items?
  hasPreviousPage: Boolean!

  # When paginating backwards, the cursor to continue.
  startCursor: String
}

type Query {
  article(slug: String!): Article
  articles(
    # Returns the elements in the list that come after the specified cursor.
    after: String

    # Returns the elements in the list that come before the specified cursor.
    before: String

    # Returns the first _n_ elements from the list.
    first: Int

    # Returns the last _n_ elements from the list.
    last: Int
    tag: String
  ): ArticleConnection!
  tags: [String!]!
  user(username: String!): User
  viewer: Viewer
}

# Autogenerated input type of SignInUser
input SignInUserInput {
  # A unique identifier for the client performing the mutation.
  clientMutationId: String
  email: String!
  password: String!
}

# Autogenerated return type of SignInUser
type SignInUserPayload {
  # A unique identifier for the client performing the mutation.
  clientMutationId: String
  errors: [UserError!]!
  token: String
  viewer: Viewer
}

# Autogenerated input type of UnfavoriteArticle
input UnfavoriteArticleInput {
  # A unique identifier for the client performing the mutation.
  clientMutationId: String
  id: ID!
}

# Autogenerated return type of UnfavoriteArticle
type UnfavoriteArticlePayload {
  article: Article

  # A unique identifier for the client performing the mutation.
  clientMutationId: String
}

# Autogenerated input type of UnfollowUser
input UnfollowUserInput {
  # A unique identifier for the client performing the mutation.
  clientMutationId: String
  id: ID!
}

# Autogenerated return type of UnfollowUser
type UnfollowUserPayload {
  # A unique identifier for the client performing the mutation.
  clientMutationId: String
  user: User
}

# Autogenerated input type of UpdateArticle
input UpdateArticleInput {
  body: String!

  # A unique identifier for the client performing the mutation.
  clientMutationId: String
  description: String!
  id: ID!
  tagList: [String!]!
  title: String!
}

# Autogenerated return type of UpdateArticle
type UpdateArticlePayload {
  article: Article

  # A unique identifier for the client performing the mutation.
  clientMutationId: String
  errors: [UserError!]!
}

# Autogenerated input type of UpdateUser
input UpdateUserInput {
  bio: String

  # A unique identifier for the client performing the mutation.
  clientMutationId: String
  email: String!
  image: String
  password: String
  username: String!
}

# Autogenerated return type of UpdateUser
type UpdateUserPayload {
  # A unique identifier for the client performing the mutation.
  clientMutationId: String
  errors: [UserError!]!
  user: User
}

type User {
  articles(
    # Returns the elements in the list that come after the specified cursor.
    after: String

    # Returns the elements in the list that come before the specified cursor.
    before: String

    # Returns the first _n_ elements from the list.
    first: Int

    # Returns the last _n_ elements from the list.
    last: Int
  ): ArticleConnection!
  bio: String
  email: String!
  favoriteArticles(
    # Returns the elements in the list that come after the specified cursor.
    after: String

    # Returns the elements in the list that come before the specified cursor.
    before: String

    # Returns the first _n_ elements from the list.
    first: Int

    # Returns the last _n_ elements from the list.
    last: Int
  ): ArticleConnection!
  followedByViewer: Boolean!
  followers(
    # Returns the elements in the list that come after the specified cursor.
    after: String

    # Returns the elements in the list that come before the specified cursor.
    before: String

    # Returns the first _n_ elements from the list.
    first: Int

    # Returns the last _n_ elements from the list.
    last: Int
  ): FollowersConnection!
  id: ID!
  image: String
  username: String!
}

# An edge in a connection.
type UserEdge {
  # A cursor for use in pagination.
  cursor: String!

  # The item at the end of the edge.
  node: User
}

type UserError {
  message: String!
  path: String
}

type Viewer {
  feed(
    # Returns the elements in the list that come after the specified cursor.
    after: String

    # Returns the elements in the list that come before the specified cursor.
    before: String

    # Returns the first _n_ elements from the list.
    first: Int

    # Returns the last _n_ elements from the list.
    last: Int
  ): ArticleConnection!
  user: User!
}