https://github.com/nawodyaishan/graphql-angular-node-ts
This project demonstrates how to create a simple GraphQL API using TypeScript, Express, and Apollo Server, with an Angular client application.
https://github.com/nawodyaishan/graphql-angular-node-ts
angular api-rest apollo-client css graphql html ndoejs typescript
Last synced: 2 months ago
JSON representation
This project demonstrates how to create a simple GraphQL API using TypeScript, Express, and Apollo Server, with an Angular client application.
- Host: GitHub
- URL: https://github.com/nawodyaishan/graphql-angular-node-ts
- Owner: nawodyaishan
- License: mit
- Created: 2023-05-13T21:05:40.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-05-14T14:23:26.000Z (over 2 years ago)
- Last Synced: 2025-03-15T05:28:40.351Z (7 months ago)
- Topics: angular, api-rest, apollo-client, css, graphql, html, ndoejs, typescript
- Language: TypeScript
- Homepage:
- Size: 323 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# GraphQL API with TypeScript and Angular Client
This project demonstrates how to create a simple GraphQL API using TypeScript, Express, and Apollo Server, with an
Angular client application.## Project Structure
```
.
├── client (Angular client application)
│ ├── src
│ │ └── app
│ │ └── user (User component)
├── src (GraphQL API server)
│ ├── controllers (API controllers)
│ ├── routes (API routes)
│ ├── types (TypeScript interfaces)
│ └── utils (Utility functions and data)
└── tests (Test cases)
```## Getting Started
### Prerequisites
- Node.js (v14+ recommended)
- Angular CLI### Installation
1. Clone the repo:
2. Install dependencies:
```bash
yarn install
```3. Install client dependencies:
```bash
cd client
npm install
```### Running the API Server
1. Start the GraphQL API server:
```bash
yarn start
```The server will be running at `http://localhost:4000/graphql`.
### Running the Angular Client
1. Start the Angular client:
```bash
cd client
ng serve
```The client will be running at `http://localhost:4200`.
## Running Tests
1. Run tests for the API server:
```bash
yarn test
```## Sample GraphQL Queries
example of a GraphQL mutation that could be used to create a new user with the setUser operation:```
mutation SetUser($name: String!, $age: Int!, $address: String!) {
setUser(name: $name, age: $age, address: $address) {
id
name
age
address
}
}{
"name": "Alice",
"age": 30,
"address": "123 Main St."
}
```
example of a GraphQL query that could be used to fetch a user's information given their id:```
query GetUser($id: String!) {
getUser(id: $id) {
id
name
age
# other fields you might want to fetch
}
}{
"id": "12345"
}
```## Built With
- [TypeScript](https://www.typescriptlang.org/)
- [Node.js](https://nodejs.org/)
- [Express](https://expressjs.com/)
- [Apollo Server](https://www.apollographql.com/docs/apollo-server/)
- [Angular](https://angular.io/)## License
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.