Skip to content

Commit 236b2e9

Browse files
committed
Update README.md
1 parent dc581f8 commit 236b2e9

File tree

1 file changed

+115
-1
lines changed

1 file changed

+115
-1
lines changed

README.md

+115-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,115 @@
1-
# GraphQL_FastAPI
1+
# CRUD Operation GraphQL FastAPI with MongoDB
2+
3+
This is a sample project that demonstrates a CRUD operation GraphQL API using FastAPI, MongoDB, and Strawberry.
4+
5+
## Installation
6+
7+
1. Clone the repository:
8+
```
9+
git clone https://github.com/Shikha-code36/GraphQL_FastAPI.git
10+
11+
cd GraphQL_FastAPI
12+
```
13+
14+
2. Create and activate a virtual environment:
15+
```
16+
python3 -m venv venv
17+
source venv/bin/activate # On Linux/MacOS
18+
venv\Scripts\activate.bat # On Windows
19+
```
20+
3. Install dependencies using pip:
21+
```
22+
pip install -r requirements.txt
23+
```
24+
25+
## Usage
26+
27+
1. Make sure your MongoDB server is running on `localhost` at the default port `27017`. You can use your MongoDB server instead of localhost.
28+
29+
30+
2. Start the FastAPI server:
31+
```
32+
uvicorn main:app --reload
33+
```
34+
35+
3. The GraphQL API will be available at `http://localhost:8000/graphql`. You can access this URL in your browser or use tools like Insomnia or GraphQL Playground to interact with the API.
36+
37+
## Test
38+
39+
To run the test cases, use the following command:
40+
41+
```
42+
python -m pytest
43+
```
44+
45+
46+
## Examples
47+
48+
### Create User
49+
To create a new user, send a GraphQL mutation request:
50+
51+
```graphql
52+
mutation {
53+
createUser(name: "Shikha Pandey") {
54+
id
55+
name
56+
}
57+
}
58+
```
59+
### Update User
60+
To update a user, send a GraphQL mutation request:
61+
```
62+
mutation {
63+
updateUser(id: 1, name: "Kritika Pandey") {
64+
id
65+
name
66+
}
67+
}
68+
```
69+
### Delete User
70+
To delete a user, send a GraphQL mutation request:
71+
```
72+
mutation {
73+
deleteUser(id: 1) {
74+
id
75+
name
76+
}
77+
}
78+
```
79+
### Get All Users
80+
To get a list of all users, send a GraphQL query request:
81+
```
82+
query {
83+
users {
84+
id
85+
name
86+
}
87+
}
88+
```
89+
### Get User by ID
90+
To get a specific user by ID, send a GraphQL query request:
91+
```
92+
query {
93+
user(id: 1) {
94+
id
95+
name
96+
}
97+
}
98+
```
99+
100+
#### [Note:] Please adjust the URLs, ports, and API endpoints according to your setup.
101+
102+
## License
103+
104+
This project is licensed under the [MIT License](LICENSE).
105+
106+
## Disclaimer
107+
108+
This project is a basic implementation of a graphql and python FastApi for educational purposes. It may not be suitable for production use. Use it at your own risk.
109+
110+
## Contributing
111+
112+
Contributions to this project are welcome. If you find any issues or have suggestions for improvements, please feel free to open an issue or submit a pull request.
113+
114+
115+

0 commit comments

Comments
 (0)