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
}
}