yarn
ornpm install
yarn start
ornpm start
- Go to
http://localhost:4000
Currently, data.js
. consists of an array of users, and an array of posts.
Our server isn't aware of the POSTS
data yet: we haven't defined the Post
type in the type definitions yet, and haven't made resolvers for it.
Add a Post
type to the schema, just like the User
type. A post field's types are:
{
"id": "1",
"title": "A Cool Post",
"description": "A Cool Company",
"author": {
"id": "1",
"name": "John Doe",
"company": "A Cool Company",
"address": {
"street": "Main Street 100",
"postalCode": "123456",
"city": "Miami",
"state": "FL"
},
"website": "www.website.com",
"email": "[email protected]"
},
"body": "Lorem Ipsum"
}
It has an id as ID
, a title as String
, a description as String
, an author as User
, and body as String
.
Add the resolver functions. Users should be able to:
- Query posts individually based on their id (Hint: Look at
Query.user
) - Query all posts (Hint: Look at
Query.users
)
Add the new queries to type Query
.