January 2019
Intermediate to advanced
460 pages
10h 33m
English
Let's start by creating a schema.js inside the graphql folder. You can also stitch multiple smaller schemas to one bigger schema. This would be cleaner and would make sense when your application, types, and fields grow. For this book, one file is okay and we insert the following code into the schema.js file:
const typeDefinitions = ` type Post { id: Int text: String } type RootQuery { posts: [Post] } schema { query: RootQuery }`;export default [typeDefinitions];
The preceding code represents a basic schema, which would be able to at least serve the fake posts array from Chapter 1, Preparing Your Development Environment, excluding the users.
First, we define a new type called Post. A Post type has id as
Read now
Unlock full access