How can I get multiple users names just from their usernames?

schema-request

#1

Hello there,
I have a list of 3 users, their usernames are a, b, and c. I would like to get each one of their full names using a GraphQL query. I am quite new to how GraphQL works so I am not sure if this is even possible. From the exploring that I have done, it seems that I can only get one user at a time. Is there a way around this?


#2

Not supported. IMO, GraphQL is really the culprit here. See this question and this GraphQL issue.


#3

@nathfreder - if you’re looking to get multiple answers in one round trip, that is possible using aliases. For example:

query multiple_users{
  a: user(login:"a"){
    name
  }
  b: user(login:"b"){
    name
  }
  c: user(login:"c"){
    name
  }
}

Will return a response like (real names munged):

{
  "data": {
    "a": {
      "name": "A"
    },
    "b": {
      "name": "B"
    },
    "c": null
  },
  "errors": [
    {
      "message": "Could not resolve to a User with the login of 'c'.",
      "type": "NOT_FOUND",
      "path": [
        "c"
      ],
      "locations": [
        {
          "line": 10,
          "column": 3
        }
      ]
    }
  ]
}

The issue @mathstuf cited is about not needing to generate the alias values on the client side.