Field \”me\” of type \”User\” must have a selection of subfields

From the docs:

A GraphQL object type has a name and fields, but at some point those
fields have to resolve to some concrete data. That’s where the scalar
types come in: they represent the leaves of the query.

GraphQL requires that you construct your queries in a way that only returns concrete data. Each field has to ultimately resolve to one or more scalars (or enums). That means you cannot just request a field that resolves to a type without also indicating which fields of that type you want to get back.

That’s what the error message you received is telling you — you requested a User type, but you didn’t tell GraphQL at least one field to get back from that type.

To fix it, just change your request to include name like this:

{
  me {
    name
  }
}

… or age. Or both. You cannot, however, request a specific type and expect GraphQL to provide all the fields for it — you will always have to provide a selection (one or more) of fields for that type.

Leave a Comment