Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/tony-tvu/simple-express-react-graphql-template

Full stack app built with Express, Apollo Graphql, MongoDB, React, and TypeScript
https://github.com/tony-tvu/simple-express-react-graphql-template

apollo apollo-graphql express graphql mern mern-stack mongodb node react typescript

Last synced: 2 days ago
JSON representation

Full stack app built with Express, Apollo Graphql, MongoDB, React, and TypeScript

Awesome Lists containing this project

README

        

# Simple Apollo GraphQL

This is a simple full stack application built with Express, Apollo Graphql, MongoDB, React, and TypeScript which can be used as a template for your next project.

## Steps to Start Express Server
From terminal, cd into ``` /api ``` directory.

Start MongoDB container:
```
docker-compose up
```
OR
```
docker compose up
```

Install dependencies
```
npm install
```

Start server
```
npm start
```

If the server has started successfully, you should be able to navigate to http://localhost:8080 and see this:

``` {"message":"Simple API built with Express, Apollo GraphQL, and MongoDB."} ```

To populate test data, navigate to http://localhost:8080/graphql to use the GraphiQL tool.

Run this query with any name and age on the fourth and fifth line below:
```
mutation create {
createUser(
newUserInput: {
name: "BOB SMITH"
age: 30
}
) {
id
name
age
createdAt
updatedAt
}
}
```

To view all data using the GraphiQL tool, run:
```
query usersQuery {
getAllUsers {
id
name
age
createdAt
updatedAt
}
}
```

To find a user by ID using the GraphiQL tool, run:
```
query getUserByIDQuery {
getUserById(id: "62755d38ac344afc0af874c7") {
id
name
age
createdAt
updatedAt
}
}
```

To delete a user by ID using the GraphiQL tool, run:
```
mutation deleteMutation {
deleteUser(id: "62755d38ac344afc0af874c7")
}
```

To update a user by ID using the GraphiQL tool, run:
```
mutation updateQuery {
updateUser(
editUserInput: {
id: "62755d9c711f1dfdee0edd06"
name: "NEW NAME"
age: 51
}
) {
id
name
age
createdAt
updatedAt
}
}
```

## Steps to Start React App
From terminal, cd into ``` /client ``` directory.

Install dependencies
```
npm install
```

Start app
```
npm start
```