Apollo server is a community-maintained open-source GraphQL server.
git clone https://github.com/kevinneuman/graphql-server-example.git
or git clone [email protected]:kevinneuman/graphql-server-example.git
cd graphql-server-example
npm install
npm start
Open the browser and access GraphiQL at: http://localhost:4000/graphiql
All users
{
users {
id
username
}
}
All posts
{
posts {
id
userId
message
}
}
User with id: 1
{
user(id: 1) {
id
username
}
}
Friends for userId: 1
{
friends(userId: 1) {
userId
friendIds
}
}
All users + their posts and friends
{
users {
id
username
posts {
message
}
friends {
friendIds
}
}
}
New post by userId: 1
mutation {
addPost(userId: 1, message: "Hello from GraphiQL!") {
id
}
}
New friend for userId: 2
mutation {
addFriend(userId: 2, friendId: 3) {
friendIds
}
}