I'm trying to write a resolver in python graphql for the non-table data. For example, my dictionary is as follows:
api_list={1:"API 1", 2:"API 2"}
I want the graphql result as
[
{
"name":"API 01"
},
{
"name":"API 02"
}
]
I tried using the Query as
class Query(ObjectType):
apis = List()
def resolve_apis(self, info, api_list):
results = []
for key, value in apis_list.items():
api = {}
api[key] = value
results.append(api)
return results
But getting an error saying that: a model type is not defined. Can we write a resolver for returning dictionary elements without putting them in a Django table in real?
__init__() missing 1 required positional argument: 'of_type'