drizzle-graphql
drizzle-graphql copied to clipboard
relation breaks
package
"drizzle-graphql": "^0.7.0",
"drizzle-orm": "^0.30.10",
query
query ($entity_id: Int!, $date: String!) {
entitiesSingle(where: { id: { eq: $entity_id } }) {
financeSalaries(where: { activatedAt: { lte: $date } }) {
value
activatedAt
}
}
}
response
{
"errors": [
{
"message": "Cannot return null for non-nullable field EntitiesSelectItem.financeSalaries.",
"locations": [
{
"line": 3,
"column": 5
}
],
"path": [
"entitiesSingle",
"financeSalaries"
]
}
],
"data": {
"entitiesSingle": null
}
}
Note:
in version 0.6, everything works just fine. Updating to 0.7 got the problem. thanks
What's your drizzle schema? Can't replicate this using any of mine including the test ones.
this is my schema hope it helps
export const entities = pgTable("entities", {
id: serial("id").primaryKey().notNull(),
createdAt: timestamp("created_at").defaultNow().notNull(),
name: text("name").notNull(),
});
export const entitiesRelations = relations(entities, ({ many }) => ({
financeSalaries: many(financeSalaries),
}));
export const financeSalaries = pgTable(
"finance_salaries",
{
id: serial("id").primaryKey().notNull(),
createdAt: timestamp("created_at").defaultNow().notNull(),
activatedAt: timestamp("activated_at").defaultNow().notNull(),
value: jsonb("value").notNull(),
entityId: integer("entity_id")
.notNull()
.references(() => entities.id, {
onDelete: "restrict",
onUpdate: "cascade",
}),
},
(table) => ({
activatedAtIndex: index().on(table.activatedAt),
entityIdIndex: index().on(table.entityId),
entityIdValueUnique: unique().on(table.entityId, table.value),
}),
);
export const financeSalariesRelations = relations(
financeSalaries,
({ one }) => ({
entity: one(entities, {
fields: [financeSalaries.entityId],
references: [entities.id],
}),
}),
);
same problem but on mysql database, so it does not depend on dbms
Fixed - v0.7.2