{"record":{"id":"258b8179297ddc1c","repo":"hasura/graphql-engine","slug":"makeperformexistssubquery-only-table-relationship","errorCode":null,"errorMessage":"makePerformExistsSubquery: only table relationships currently supported","messagePattern":"makePerformExistsSubquery: only table relationships currently supported","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"dc-agents/reference/src/query.ts","lineNumber":327,"sourceCode":"      targetName: TargetName,\n      query: Query,\n    ) => QueryResponse,\n  ) =>\n  (exists: ExistsExpression, row: Record<string, RawScalarValue>): boolean => {\n    const [targetTable, joinExpression] = (() => {\n      switch (exists.in_table.type) {\n        case 'related':\n          const relationship = findRelationship(exists.in_table.relationship);\n          const joinExpression = createFilterExpressionForRelationshipJoin(\n            row,\n            relationship,\n          );\n          const relationshipTarget = relationship.target;\n          switch (relationshipTarget.type) {\n            case 'table':\n              return [relationshipTarget.name, joinExpression];\n            default:\n              throw new Error(\n                'makePerformExistsSubquery: only table relationships currently supported',\n              );\n          }\n        case 'unrelated':\n          return [exists.in_table.table, undefined];\n        default:\n          return unreachable(exists.in_table['type']);\n      }\n    })();\n\n    if (joinExpression === null) return false;\n\n    const subquery: Query = {\n      aggregates: {\n        count: { type: 'star_count' },\n      },\n      limit: 1, // We only need one row to exist to satisfy this expresion, this short circuits some filtering\n      where:","sourceCodeStart":309,"sourceCodeEnd":345,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/dc-agents/reference/src/query.ts#L309-L345","documentation":"Thrown while evaluating an exists expression (type 'exists', in_table.type 'related') whose relationship target is not a table. The reference agent's query engine can only run exists subqueries against concrete table targets, so any other relationship target type hits the default branch and errors immediately.","triggerScenarios":"A QueryRequest where filter contains { type: 'exists', in_table: { type: 'related', relationship: 'r' } } and the named relationship's target type is anything other than 'table' in the schema/static data.","commonSituations":"Custom connector backends that emit non-table relationship targets; malformed or hand-built QueryRequest JSON; schema metadata drift where a relationship target type changed between versions.","solutions":["Inspect the schema for the relationship referenced in exists.in_table.relationship and confirm its target is { type: 'table', name: ... }.","If you control the QueryRequest, rewrite the exists expression to use in_table: { type: 'unrelated', table: '...' } with an explicit where clause instead of a non-table related target.","Upgrade/patch the connector backend so it only produces table-typed relationship targets."],"exampleFix":"// before\nwhere: {\n  type: 'exists',\n  in_table: { type: 'related', relationship: 'nonTableRel' },\n  where: { type: 'equal', ... },\n}\n\n// after\nwhere: {\n  type: 'exists',\n  in_table: { type: 'unrelated', table: 'Album' },\n  where: { type: 'and', expressions: [joinClause, { type: 'equal', ... }] },\n}","handlingStrategy":"validation","validationCode":"const rel = schema.table_relationships[table]?.[existsExpr.in_table.relationship];\nif (rel?.target.type !== 'table') throw new Error('unsupported relationship target for exists');","typeGuard":"const isTableTarget = (t: { type: string } | undefined): t is { type: 'table'; name: string } =>\n  t?.type === 'table';","tryCatchPattern":null,"preventionTips":["Validate exists expressions against schema relationship targets before sending","Prefer in_table type 'unrelated' with explicit join where-clauses for custom backends"],"tags":["hasura","data-connector","exists-subquery","unsupported-feature"],"backgroundTag":"unsupported-relationship-type","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}