firebase-tools
firebase-tools copied to clipboard
Unable to query / mutate a table after adding fields referencing the same type
As I am working with DataConnect, I am trying to implement a versionning system where given an "Application" , it may have different "Snapshots", where each points to the previous and next version, if those exists respectively.
Initially, I was unable to reference the Snapshot table/type and dataconnect would give me the compilation error
On Snapshot.previous @ref(references): Reference another reference field Snapshot.applicationFirebase Data Connect: Compiler
whenever I tried to do so. And to work around that, I had to manually add a unique id field of type UUID. Then, reference the specific id field each time I want to reference my Snapshot as in Snapshot @ref(references: "id"). Using that, the compiler doesn't displays errors anymore, both for my schema and my CRUD operations.
But then, as soon as I try to access the Application whether for a query or a mutation, the emulator will crash immediately and give me the error
Error Response: {"code":9,"message":"cannot prepare SQL statement:\nSELECT coalesce(json_agg(j), '[]') FROM (SELECT jsonb_build_object('currentId', REPLACE(CAST(( \"current_id\" ) AS text), '-', '')) AS j FROM \"public\".\"application\" LIMIT 100) AS x\nSQL Error: pq: unexpected message 'E'; expected ReadyForQuery","details":[]}
at Yg.handleEmulatorResponse (c:\{...}\extensions\googlecloudtools.firebase-dataconnect-vscode-1.3.1\dist\extension.js:8:5866458)
at Yg.executeGraphQL (c:\{...}\extensions\googlecloudtools.firebase-dataconnect-vscode-1.3.1\dist\extension.js:8:5868703)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at d (c:\{...}\extensions\googlecloudtools.firebase-dataconnect-vscode-1.3.1\dist\extension.js:8:5860714)
and I get a similar error if i try to access a Snapshot
But I notice that if I comment out my reference fields, everything works fine !
Here is the schema:
type Application @table {
current: Snapshot @ref(references: "id")
latest: Snapshot @ref(references: "id")
}
type Snapshot @table (key: [ "application", "version"]) {
# The id property must be there, else, can't self reference
id: UUID! @unique
application: Application!
version: String!
previous: Snapshot @ref(references: "id")
next: Snapshot @ref(references: "id")
}
Expected Behaviour: To be able to query and mutate my Applications and Snapshots normally and access linked resources (prev/next, current/latest navigation) Actual Behaviour: Emulator crashes unexpectedly when any interaction is initiated with the specified types
Environment
firebase-tools: 14.3.1
firebase dataconnect vscode extension: 1.3.1
node: v22.14.0 **
operating system: windows
terminal: powershell
This issue does not seem to follow the issue template. Make sure you provide all the required information.