Search code examples
graphqlapolloapollo-clientgraphql-jsapollo-server

How to create an array of arrays as input in ApolloGraphQL


How can I create an array of arrays as inputs in ApolloGraphQL?

For instance, how should be the Schema for a query like this:

{
    Users(Id:1, Filters:[["Id",">", "1"], ["Id","<","3"]]) {
      Id
      Name
    }
}

I have tried the following schema but no luck:

const typeDefs = gql`
  type Query{
      Users(
        Id: ID,
        Filters: [[String, String, String]]
      )
   }
 `;

What I am trying to achieve here is an Input type which is a List of Lists, with each of the child lists containing exactly 3 strings. So it can be called like this within the function: Filters:[["Id",">", "1"], ..]


Solution

  • Seems like it was easier than I though, would be enough using [[String]]:

    const typeDefs = gql`
      type Query{
          Users(
            Id: ID,
            Filters: [[String]]
          )
       }
     `;