| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
This is a sample project that demonstrates a CRUD operation GraphQL API using FastAPI, MongoDB, and Strawberry.
git clone https://github.com/Shikha-code36/GraphQL_FastAPI.git cd GraphQL_FastAPI
python3 -m venv venv source venv/bin/activate # On Linux/MacOS venv\Scripts\activate.bat # On Windows
pip install -r requirements.txt
Make sure your MongoDB server is running on localhost at the default port 27017. You can use your MongoDB server instead of localhost.
Start the FastAPI server:
uvicorn main:app --reload
To run the test cases, use the following command:
python -m pytest
To create a new user, send a GraphQL mutation request:
mutation {
createUser(name: "Shikha Pandey") {
id
name
}
}To update a user, send a GraphQL mutation request:
mutation {
updateUser(id: 1, name: "Kritika Pandey") {
id
name
}
}
To delete a user, send a GraphQL mutation request:
mutation {
deleteUser(id: 1) {
id
name
}
}
To get a list of all users, send a GraphQL query request:
query {
users {
id
name
}
}
To get a specific user by ID, send a GraphQL query request:
query {
user(id: 1) {
id
name
}
}
This project is licensed under the MIT License.
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.
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.
| Back | FazBrowse Home | New Git URL |