- Notifications
You must be signed in to change notification settings - Fork1
GraphQL implementation in FastAPI using Strawberry
License
Shikha-code36/GraphQL_FastAPI
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
This is a sample project that demonstrates a CRUD operation GraphQL API using FastAPI, MongoDB, and Strawberry.
- Clone the repository:
git clone https://github.com/Shikha-code36/GraphQL_FastAPI.gitcd GraphQL_FastAPI
- Create and activate a virtual environment:
python3 -m venv venvsource venv/bin/activate # On Linux/MacOSvenv\Scripts\activate.bat # On Windows
- Install dependencies using pip:
pip install -r requirements.txt
Make sure your MongoDB server is running on
localhost
at the default port27017
. You can use your MongoDB server instead of localhost.Start the FastAPI server:
uvicorn main:app --reload
- 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.
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") {idname }}
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 theMIT 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.
About
GraphQL implementation in FastAPI using Strawberry
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.