https://github.com/leandrorsant/graphql-server
This is an expressGraphQL API
https://github.com/leandrorsant/graphql-server
express-graphql nodejs-api
Last synced: about 1 year ago
JSON representation
This is an expressGraphQL API
- Host: GitHub
- URL: https://github.com/leandrorsant/graphql-server
- Owner: leandrorsant
- Created: 2023-10-29T15:04:37.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-10-29T15:22:56.000Z (over 2 years ago)
- Last Synced: 2025-01-23T08:15:26.820Z (over 1 year ago)
- Topics: express-graphql, nodejs-api
- Language: JavaScript
- Homepage:
- Size: 59.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# GraphQL Server
This is a GraphQL API which fetches data from an in-memory database to demonstrate what this library can do to reduce the amount of requests needed to get resourcers from a server.
# Getting started
Clone this repository:
```
git clone ...
```
Install dependencies:
```
npm i
```
Run server:
```
npm run devStart
```
This project doesn't have a frontend url, but it has a GraphiQL interface at (http://localhost:5000/graphql) once the server is running. You can use GraphiQL to test queries as demonstrated in the screenshots bellow.
# Query samples
List all books:
```
{
books {
id,
name,
authorId,
}
}
```
List all Authors:
```
{
authors {
id,
name
}
}
```
Add a book:
```
mutation {
addBook(name: "new book", authorId: 1) {
id
name
}
}
```
Add an author:
```
mutation {
addAuthor(name: "new author") {
id
name
}
}
```
Update a book:
```
mutation {
updateBook(id: 1, name:"new name", authorId:1) {
id,
name
}
}
```
Update an author:
```
mutation {
updateAuthor(id: 1, name:"new name") {
id,
name
}
}
```
Remove a book:
```
mutation {
removeBook(id: 1) {
id
name
}
}
```
Remove an author:
```
mutation {
removeAuthor(id: 1) {
id
name
}
}
```
# Screenshots
