January 2019
Intermediate to advanced
460 pages
10h 33m
English
Let's create a User type and use it with our posts. First, add it somewhere to the schema:
type User { avatar: String username: String}
Now that we have a User type, we need to use it inside the Post type. Add it to the Post type as follows:
user: User
The user field allows us to have a sub-object inside our posts with the post's author information.
Our extended query to test this looks like the following:
"query":"{ posts { id text user { avatar username } }}"
You cannot just specify the user as a property of the query. Instead, you need to provide a sub-selection of fields. This is required whenever you have multiple GraphQL types stacked inside each other. Then, you need to select the fields your ...
Read now
Unlock full access