Drizzle GraphQL bug with SQLite JSON (Turso)
Hey, just found that it doesn't "decode/extract" the JSON when we have
text({ mode: 'json' }).$type<{ [key:
0x${string}]: number }>().default({})
I'm using GraphQL Yoga to check the seeded data, and it shows that column as plain string, not extracted json. Probably bug in your graphql resolvers.
Or this is intentional? I don't see why would it tho.3 Replies
The
royalties
field is "json type" in the schema.
Here's the full schema:
When i try to read team
or links
it throws error too.
Oh, just seen i've got errors on the terminal:
I'm guessing that's the value from the database but it cannot read it properly from text(mode: json)
I'm also having similar error when read timestamps
neither integer({ mode: timestamp })
, nor with .defaultNow
It works when it's passed as orderBy: { created_at: {direction: asc } }
, but know when i ask for the field
oh wait, that last thing worked, okay. I was setting created_at: Date.now()
when inserting.
The OP is still valid problem tho.Hi! I think it's because the actual mapping between parsed / stringified json is made by the orm, meaning, if you do the query via:
you will get the parsed variant in the result.
Since you are making the query in GraphQL Yoga, it returns the real value, just as it is stored in your sqlite database - as a text
Yeah, on orm query it works, but not on the graphql frontend. That's the thing if it was returning it like stringified json array it would still be okay, like it does for
royalties
which it returns like stringified object. But instead it throws errors for that links
case.
I'm not doing anything for the graphql, it's drizzle-graphql
and it should handle sqlite json fields properly.