Skip to content

Latest commit

ย 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ“š GraphQL Backend โ€“ Publishers, Authors & Books

This project is a GraphQL API built with Express.js and Apollo Server. It demonstrates how to manage relationships between Publishers, Authors, and Books with Queries & Mutations including full CRUD operations.

๐Ÿš€ Features

โšก GraphQL API with Express + Apollo Server

๐Ÿ”Ž Queries:

Get all publishers, authors, and books

Get a single publisher, author, or book by ID

โœ๏ธ Mutations:

Add, Edit, and Delete Publishers, Authors, and Books

๐Ÿ“ฆ In-memory data storage (easy to swap with a database later)

๐Ÿ“‚ Project Structure graphql-backend/ โ”‚โ”€โ”€ package.json โ”‚โ”€โ”€ server.js # Entry point โ”‚โ”€โ”€ schema.js # GraphQL typeDefs โ”‚โ”€โ”€ resolvers.js # Query & Mutation resolvers

๐Ÿ“ฆ Installation

Clone the repo:

git clone https://github.com/your-username/graphql-backend.git cd graphql-backend

Install dependencies:

npm install express apollo-server-express graphql npm install --save-dev nodemon

โ–ถ๏ธ Running the Server

Start the server in development mode:

npm run dev

or with plain Node.js:

node server.js

By default, the server runs at:

http://localhost:4000/graphql

๐Ÿ›  Example Queries Get all authors with their books query { authors { id name books { title } } }

Get a single book by ID query { book(id: "1") { id title publishedYear } }

โœ๏ธ Example Mutations Add a new Publisher mutation { addPublisher(name: "Oโ€™Reilly", location: "USA") { id name location } }

Edit an Author mutation { updateAuthor(id: "2", name: "Updated Name") { id name } }

Delete a Book mutation { deleteBook(id: "3") { id title } }

๐Ÿงช Using Apollo Sandbox

Once the server is running, open: ๐Ÿ‘‰ http://localhost:4000/graphql

Apollo Sandbox will load in your browser where you can test Queries & Mutations interactively.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages