Page MenuHomePhabricator

🕸️ Add functionality to query items by statement properties and values in GraphQL
Closed, ResolvedPublic13 Estimated Story Points

Description

This functionality will allow for a user to find a particular set of QIDs that match a criteria. For example, looking for all items that have occupation = actor

searchItems(query: Filter!): [ItemSearchResult]!

type ItemSearchResult {
	id: ItemId!
        label(languageCode: String!): String
        description(languageCode: String!): String
}

input Filter {
    and: [Filter!]

    property: PropertyId
    value: String
}

Note that the value could be omitted to indicate that the query criteria means "any statement with predicate property", i.e. not including any specific value.

In the first increment only properties with "data value type" string or wikibase-entityid are allowed to be used in filters.
If a property of a different data value type is used in any filter, the API should reject the query and return an error to the client.

Pagination is not considered in this iteration of the functionality. The API should return a list of up to 50 results.

Example

searchItems(query: {
    and: [
        { property: “P106”, value: “Q33999” }, # occupation=actor
        { property: “P21”, value: “Q6581072” } # sex or gender=female
    ]
}) {
  label(languageCode: “en”)
}

Acceptance criteria:

  1. Be able to look up items by their statement properties and values
  2. The return type is a list (even if only one element is returned, it will be a list of length 1)
  3. User can query by multiple statement properties and values

Task breakdown:

  • create a very simple happy path implementation that only returns a list of Item IDs
    • create a haswbstatement keyword search and call CirrusSearch service
      • include a hard limit of 50 results
      • include the Item namespace to search in
    • create a SearchItems use case with the query as request
    • for testing, a simple InMemory search by statement property is needed
  • fetch labels
    • use the existing use case
  • fetch description
    • create a new BatchGetItemDescriptions use case
  • validation:
    • filter (no fields, all fields, illegal query, unsupported property data types)
  • include a limit on the number of searches allowed in one request (maybe 1 for now?)
  • fail gracefully when WikibaseCirrusSearch is not enabled

Event Timeline

Ifrahkhanyaree_WMDE renamed this task from Inverse lookup in GraphQL to [WIP] Inverse lookup in GraphQL.Sep 8 2025, 11:35 AM
Ifrahkhanyaree_WMDE renamed this task from [WIP] Inverse lookup in GraphQL to Inverse lookup in GraphQL.Sep 30 2025, 11:12 AM
Ifrahkhanyaree_WMDE updated the task description. (Show Details)
Ifrahkhanyaree_WMDE moved this task from Backlog to Later on the Wikibase GraphQL board.
Ifrahkhanyaree_WMDE renamed this task from Inverse lookup in GraphQL to Add functionality to query items and properites by statement values in GraphQL.Oct 7 2025, 9:00 AM
Ifrahkhanyaree_WMDE updated the task description. (Show Details)
Jakob_WMDE renamed this task from Add functionality to query items and properites by statement values in GraphQL to Add functionality to query items and properties by statement values in GraphQL.Oct 8 2025, 11:02 AM
Jakob_WMDE renamed this task from Add functionality to query items and properties by statement values in GraphQL to Add functionality to query items by statement properties and values in GraphQL.Oct 23 2025, 9:14 AM
Jakob_WMDE updated the task description. (Show Details)
Jakob_WMDE updated the task description. (Show Details)
Jakob_WMDE set the point value for this task to 13.Oct 23 2025, 9:21 AM
Silvan_WMDE renamed this task from Add functionality to query items by statement properties and values in GraphQL to 🕸️ Add functionality to query items by statement properties and values in GraphQL.Nov 27 2025, 1:03 PM
Jakob_WMDE subscribed.

The work for this story is done but unfortunately it is not product-verifiable yet since we don't have GraphQL on beta yet, and patch demo doesn't support CirrusSearch.