Skip to content

Latest commit

 

History

History
38 lines (29 loc) · 749 Bytes

File metadata and controls

38 lines (29 loc) · 749 Bytes

Build our own GraphQL Schema

You are building a database for a Library. Here are the specifications:

  • A library has many books
  • Book has ISBN
  • Book has publish date
  • Book has many authors
  • Book has many categories

Sample Schema

type Author {
  name: String
}

type Category {
  name: String
}

type Book {
  isbn: String
  title: String
  publishDate: String
  authors: [Author]
  categories: [Category]
}

type Query {
  allBooks: [Book]
  book(isbn: String!): Book
}

As a file

The "Query" type is special: it lists all of the available queries that clients can execute, along with the return type for each. In this case, the "books" query returns an array of zero or more Books (defined above).