Skip to content

Commit

Permalink
chore(lab-2851): add a warning when trying to filter by more than 10+…
Browse files Browse the repository at this point in the history
… partial external id (#1684)
  • Loading branch information
baptiste-olivier authored Apr 22, 2024
1 parent f9ff777 commit bd153d1
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/kili/adapters/kili_api_gateway/asset/mappers.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
"""GraphQL payload data mappers for asset operations."""

import warnings

from kili.domain.asset import AssetFilters

MAX_PARTIAL_EXTERNAL_IDS_FILTER = 10


def asset_where_mapper(filters: AssetFilters):
"""Build the GraphQL AssetWhere variable to be sent in an operation."""
if (
filters.external_id_in is not None
and len(filters.external_id_in) > MAX_PARTIAL_EXTERNAL_IDS_FILTER
):
warnings.warn(
f"Requesting more than {MAX_PARTIAL_EXTERNAL_IDS_FILTER} partial external IDs"
"in a single query is deprecated. You can use the `external_id_strictly_in`"
f"field to filter by more than {MAX_PARTIAL_EXTERNAL_IDS_FILTER} external IDs. "
"This limit will be enforced in next versions.",
stacklevel=5,
)
return {
"id": filters.asset_id,
"project": {
Expand Down

0 comments on commit bd153d1

Please sign in to comment.