I selected "Allow Multiple" on a Text field but now none of my Queries work

I’m building a project management app (a lot like Trello) and on each task, I want to be able to store multiple tags. I added a tags field to my Tasks table of type text and selected “Allow Multiple”. However, none of my queries work when trying to search by tasks with certain tags.

Something like this:

Tasks:
Title: text
Description: text
Tags: text - allow multiple

query($tag: String) {
    TasksList(filter: {
        tags: {
           contains: "$tag"
        }
    }) {
       items {
          id
       }
    }
}

Am I doing something wrong?

1 Like

Hey @axel_j -

The allow multiple option changes a field of the specified type (Text, in this case) from being a single value of the type to an array of values for the type. This is really useful for storing some arbitrary information on a table, though it doesn’t allow for search at this time.

Here’s a good example:

FriendsTable
    Name:Text
    Nicknames:Text(ALLOW_MULTIPLE)

GraphQL Query

query {
  friendsList(filter: {
    name: {
      equals: "Thomas"
    }
  }) {
    items {
      name
      nicknames
    }
  }
}

Query Result

{
  "data": {
    "friendsList": {
      "items": [
        {
          "name": "Thomas",
          "nicknames": [
            "Tom",
            "Tommy",
            "Timmy",
            "T-bone"
          ]
        }
      ]
    }
  }
} 

In this example, we wouldn’t have been able to filter on the Nicknames values. However, the data in them was received as an array.

If you intended in having multiple related values - like “Tags” - it’s better to practice creating a separate table for that type and relating the two tables.

If you check out the documentation here, you can find more info too! https://docs.8base.com/8base-console/platform-tools/data-builder