graphql-go / graphql-go/graphql

returning a map from resolver of list

Open
#609 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
10.1k
Forks
845
PR merge metrics
No merged PRs in 30d

Description

I get an error "User Error: expected iterable, but did not find one for field ..." if I return a map from the resolver. A slice works fine. Why is a map not iterable? Is there a way to do this.? I need a map for efficiency of lookup. I know I can use a slice and create my own index but it would be simpler and less error-prone if the graphql package could iterate a map.

(Sorry if this has been asked before but I have searched for a long time and found nothing)

```
racesQuery = Field{
Type: NewList(raceType),
Resolve: func(params ResolveParams) (interface{}, error) {
return races, nil // error if races is a map, no error if races is a slice
},
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.