drizzle-team / drizzle-graphql

Automatically generate GraphQL schema or customizable schema config fields from Drizzle ORM schema
https://www.npmjs.com/package/drizzle-graphql
Apache License 2.0
34 stars 1 forks source link

Bug when reusing types from tables that are not single word #12

Closed ybtam closed 3 weeks ago

ybtam commented 3 weeks ago

Description: When I try to create a new mutation or query whiles reusing existing types, it returns me this error, when the table name is not a single word.

Error: `Error: Expected undefined to be a GraphQL nullable type.

Code:

export const users = pgTable('users', {
  id: serial('id').primaryKey(),
  name: text('name').notNull()
})

export const userLogs = pgTable('user_logs', {
  id: serial('id').primaryKey(),
  log: text('log').notNull(),
  userId: serial('user_id').notNull(),
})

 new GraphQLSchema({
    query: new GraphQLObjectType({
      name: "Query",
      fields: {
        ...entities.queries,
        getUserLogs: {
          resolve: () => [],
          type: new GraphQLList(new GraphQLNonNull(entities.types.UserlogsItem)),
        }
      },
    }),
    mutation: new GraphQLObjectType({
      name: "Mutation",
      fields: {
        ...entities.mutations
      }
    }),
    types: [...Object.values(entities.types), ...Object.values(entities.inputs)],
  });
Sukairo-02 commented 3 weeks ago

v0.8.3 - fixed