Skip to content

[pending DataSpaceBackend#52] test(api): SDK GraphQL query field names match live schema - #185

Draft
saqibmanan wants to merge 1 commit into
CIfrom
test-sync/DataSpaceBackend-pr52
Draft

saqibmanan wants to merge 1 commit into
CIfrom
test-sync/DataSpaceBackend-pr52

Conversation

@saqibmanan

@saqibmanan saqibmanan commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Pending: covers open CivicDataLab/DataSpaceBackend#52 (head 97260a83054054f555dfed822d294c12fb7ebc44), "Dataspace sdk" — "Corrected the get ai model graphql query in sdk", open since 2025-12-16, base dev. Skipped in CI until it merges. Safe to merge before it.

What the source PR actually changes

dataspace_sdk/ is a Python client SDK that lives inside the DataSpaceBackend repo (not a separately deployed service). dataspace_sdk/resources/aimodels.py and datasets.py hardcode GraphQL query strings. The real diff (not just the title) is:

  • aiModel(id: $id) → getAiModel(modelId: $id) (also drops endpoints.name, which isn't a real field)
  • dataset(id: $id) → getDataset(datasetId: $id), createdAt/updatedAt → created/modified, resources.title → resources.name, resources.fileDetails/resources.schema from scalars to objects ({ format } / { fieldName })

Confirmed live on the real dev schema right now, independent of this PR merging (the backend already has these fields — this PR only fixes the SDK's hardcoded query text to match):

query GetAIModel($id: UUID!) { aiModel(id: $id) { id name } }
-> "Cannot query field 'aiModel' on type 'Query'. Did you mean 'aiModels' or 'getAiModel'?"

query GetDataset($id: UUID!) { dataset(id: $id) { id title createdAt } }
-> "Cannot query field 'dataset' on type 'Query'. Did you mean 'datasets' or 'getDataset'?"

Why pending_pr, and why not readonly

Nothing is deployed anywhere when this SDK PR merges — it's a client library, not a server. There is no server-side "before" vs "after" to point at (the schema itself doesn't change). What's gated by pending_pr is the query text, which only exists in the DataSpaceBackend repo once #52 merges — the schema-validity check itself is already true today, independent of the merge. Not readonly: that marker is for the merged-PR prod-safety gate (§7), unrelated to this pending-PR gate (§9).

Categories

api + smoke on /api/graphql (anonymous POST, structural/schema validation only — no mutation, no real record touched). A nonexistent id is used deliberately in both tests so this checks field names on the schema, never a specific record.

Tests added

  • test_sdk_aimodel_query_matches_live_schema — sends PR#52's exact new AI-model query text (copied verbatim from the diff) and asserts no "Cannot query field" error.
  • test_sdk_dataset_query_matches_live_schema — same, for the new dataset query.

Proof (pasted)

Precondition, confirmed: git show origin/CI:conftest.py | grep _pending_pr_state finds the hook.

Marker present, PR not merged — SKIPPED with the correct reason:

pytest tests/api/smoke/test_api_025_sdk_query_field_names.py -v -rs
SKIPPED [2] pending_pr DataSpaceBackend#52: not merged yet

Collected under CI's real marker filter:

pytest tests/api/smoke -m "smoke" --collect-only -q
... test_sdk_aimodel_query_matches_live_schema
... test_sdk_dataset_query_matches_live_schema
52/127 tests collected

Green — marker temporarily removed, run against the live dev schema with the PR's new query text:

API_BASE_URL=https://dev.api.civicdataspace.in pytest ... -v
test_sdk_aimodel_query_matches_live_schema PASSED
test_sdk_dataset_query_matches_live_schema PASSED
2 passed

Red — same run, with the query text swapped for the exact old (pre-fix) field names, marker still removed:

FAILED test_sdk_aimodel_query_matches_live_schema
  AssertionError: ... is not schema-valid: [{'message': "Cannot query field 'aiModel' on type 'Query'. Did you mean 'aiModels' or 'getAiModel'?", ...}]
FAILED test_sdk_dataset_query_matches_live_schema
  AssertionError: ... is not schema-valid: [{'message': "Cannot query field 'dataset' on type 'Query'. Did you mean 'datasets' or 'getDataset'?", ...}]
2 failed

Both fail at the intended assertion, confirming this methodology genuinely catches the bug #52 fixes.

Gaps / notes for the reviewer

  • This only validates query shape, not the SDK method wrappers around it. Reading the PR's full diff, DatasetsResource.get_by_id() still does response.get("data", {}).get("dataset", {}) after the fix — but the field is now getDataset, not dataset, so even with the corrected query text, that line will always return {}. This looks like a residual bug in fix: scope SDG Goals and Geography locators to combobox role #52 itself that this coverage cannot catch (it would need to import and execute the actual dataspace_sdk package, which isn't a dependency of this test repo). Flagging for the PR author/reviewer, not fixing it here.
  • Once fix: scope SDG Goals and Geography locators to combobox role #52 merges, re-run with -rs and confirm the summary shows 2 passed, not skips (the usual "skipped is not passed" check).

…kend#52)

Pending: covers open CivicDataLab/DataSpaceBackend#52 (head 97260a8).
Skipped in CI until it merges. Safe to merge before it.

dataspace_sdk's aimodel/dataset GraphQL query strings use field names that
do not exist on the live schema (aiModel/dataset instead of
getAiModel/getDataset). #52 fixes this. These tests send the PR's exact new
query text to the live dev endpoint and assert it is schema-valid.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant