Reputation: 629
Using Python's fast-api, I implemented a POST endpoint which will take request body something like below and will do some sort of processing and will return resultant dictionary to the client as shown below.
RequestBody:(user details)
{
"0": {
"details": [
{"name": "sam", "designation": "student"},
{"name": "raj", "designation": "worker"},
]
},
"1": {
"details": [
{"name": "ram", "designation": "employer"},
{"name": "sekhar", "designation": "engineer"},
]
},
}
Response:(user details with ranks)
{
"ranks": [
{
"id": "0",
"rank": 1,
},
{
"id": "1",
"rank": 2,
},
],
"details": [
{"id": "0", "name": "sam", "rank": 1},
{"id": "0", "name": "raj", "rank": 1},
{"id": "1", "name": "ram", "rank": 2},
{"id": "1", "name": "sekhar", "rank": 2},
],
}
I achieved the proper result in fast-api(REST-apis).
My Goal:
My goal is to achieve the similar thing in Graphql(fastapi, Strawberry module)
. I did some research about Strawberry module and found that, I can achieve this using mutations
I am going through some docs and tutorials about Strawberry library but didnt find any option(mutations) to work with this kind of nested data.
I am only finding simple approaches to work with mutations something like this: https://github.com/itsmaheshkariya/cautious-octo-disco/blob/main/type/user.py#L8
Can any one help me in developing Graphql mutations for this nested data?
Upvotes: 1
Views: 363