Skip to content

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

Notifications You must be signed in to change notification settings

tony-tvu/simple-express-react-graphql-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published