Skip to content

This is an example setup of an API server using GraphQL on a MongoDB server with Mongoose

Notifications You must be signed in to change notification settings

tvrbo-pro/TvrboGraphQL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tvrbo GraphQL

This is an example setup of an API server using GraphQL on a MongoDB server with Mongoose.

Setup

npm install
node .

Open http://localhost:8080/graphiql on your browser and copy the following sample queries:

query listPosts {
	posts {
		_id
		title
		content
		date
		comments {
			_id
			content
			date
		}
	}
}
query getPost {
	post(_id: "593da891a2ac8d808201566d") {  # replace it with an existing ID
		_id
		title
		content
		date
	}
}
query getComment {
	comment(_id: "593de5842a5a0184e1f3f4f5") {  # replace it with an existing ID
		_id
		content
		date
		post {
			_id
			title
			content
		}
	}
}
mutation createPost {
	createPost(title:"Hey", content:"you") {
		_id
		title
		content
		date
	}
}
mutation createComment {
	createComment(post:"593da891a2ac8d808201566d", content:"This is a comment") {  # replace the post id with an existing ID
		_id
		content
		post {
			_id
			title
			content
			date
		}
	}
}

Run MongoDB on your computer, create some posts/comments and replace the _id values above by the real id's once they exist.

Cheatsheet

About

This is an example setup of an API server using GraphQL on a MongoDB server with Mongoose

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published