Hot Chocolatev12
This is documentation for v12, which is no longer actively maintained.
For up-to-date documentation, see the latest stable version.

Lists

GraphQL allows us to return lists of elements from our fields.

SDL
type Query {
users: [User]
}

Clients can query list fields like any other field.

GraphQL
{
users {
id
name
}
}

Querying a list field will result in an ordered list containing elements with the specified sub-selection of fields.

Learn more about lists here.

Usage

Lists can be defined like the following.

If our field resolver returns a list type, e.g. IEnumerable<T> or IQueryable<T>, it will automatically be treated as a list type in the schema.

C#
public class Query
{
public List<User> GetUsers()
{
// Omitted code for brevity
}
}