edgedb-js
edgedb-js copied to clipboard
QueryError: cannot assign to __type__
I'm running the following query using the query builder.
const query = e.select(e.Entity, ()=> ({ name: true, __type__: { id: true, name: true }}))
But I'm getting the following error
QueryError: cannot assign to __type__
at RawConnection._parseErrorMessage (/Users/abdellah/workspace/scrimba/scrimba-data-playground/node_modules/edgedb/dist/baseConn.js:276:21)
at RawConnection._parse (/Users/abdellah/workspace/scrimba/scrimba-data-playground/node_modules/edgedb/dist/baseConn.js:418:34)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async RawConnection.fetch (/Users/abdellah/workspace/scrimba/scrimba-data-playground/node_modules/edgedb/dist/baseConn.js:698:61)
at async ClientConnectionHolder.retryingFetch (/Users/abdellah/workspace/scrimba/scrimba-data-playground/node_modules/edgedb/dist/client.js:178:26)
at async Client.query (/Users/abdellah/workspace/scrimba/scrimba-data-playground/node_modules/edgedb/dist/client.js:468:20)
at Datahose.subscribe (/Users/abdellah/workspace/scrimba/scrimba-data-playground/app/lib/datahose.imba:93:22) {
source: undefined
}
Here is the query generated by the query builder:
'WITH __scope_0_Entity := DETACHED default::Entity
SELECT __scope_0_Entity {
id,
name,
__type__ := ( WITH __scope_1_Type := __scope_0_Entity.__type__ SELECT __scope_1_Type { name } )
}
And the query itself fails in edgedb
Ran into the same issue.
I was able to extract the information in a different way:
const query = e.select(e.Entity, (dbEntity)=> ({ name: true, type: dbEntity.__type__.name }))
This appears to be fixed in the latest version and has test coverage.