Page MenuHomePhabricator

Simplify the `query` param in the searchItems field
Closed, ResolvedPublic2 Estimated Story Points

Description

Given that we will not support the OR operator (T415279) in the query param of the searchItems field in the first version of the Wikibase GraphQL API, we don't need the type definition to be recursive for now. This will reduce our own code and makes the schema less complex, which in turn makes it easier for users to construct queries.

This should be done in a way that is forward-compatible, so that any queries valid now will still be valid if we ever expand the functionality to allow OR or arbitrary nesting.

Event Timeline

Change #1242383 had a related patch set uploaded (by Kim.pham; author: Kim.pham):

[mediawiki/extensions/Wikibase@master] GQL: Remove ability for searchItems to have recursive ItemSearchFilter

https://gerrit.wikimedia.org/r/1242383

Change #1242383 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] GQL: Remove ability for searchItems to have recursive ItemSearchFilter

https://gerrit.wikimedia.org/r/1242383

The latest schema you will always find in the gerrit code repository as documented in the Wikibase GraphQL wiki page. However, "latest" is not what is needed to verify this task, which is already overwritten by the OR operator task T415279.

So the schema that got introduced with this, you can find in the corresponding gerrit change (see "Related Changes in Gerrit" above) and the interesting part about it is this:

"Filter used to match items by their statements. Supports simple property/value matching or combining multiple filters with AND."
input ItemSearchFilter {
  "Combine multiple conditions using AND operator. Requires at least two conditions, all of which must match. Cannot be used together with the property field."
  and: [ItemSearchCondition!]
  property: PropertyId
  value: String
}

"A single property/value condition used in item search."
input ItemSearchCondition {
  property: PropertyId
  value: String
}

With this schema change, nested search filters are no longer allowed because all search conditions need to be put into a single and: list now. This changes via T415279, where we introduce the or: oparator which is allowed either on the top level or inside the list of and: conditions.

You should also be able to see all this in the schema docs section of your favourite API client or the GraphiQL explorer.

since I verified that one and it works perfectly, moving this over to done