Skip to content

[Drizzle plugin] Returning from relational queries #1558

@shadoworion

Description

@shadoworion

I think, it's a problem with new versions of drizzle beta.
Drizzle version: 1.0.0-beta.1-0ec754e (also before this version, it happens)

builder.queryField("trxMap_history", (t) =>
  t.drizzleField({
    type: ["trxMapHistory"],
    args: {
      sourceTrxId: t.arg.string({ required: true }),
    },
    resolve: async (_query, _root, { sourceTrxId }) => {
      return await db.query.trxMapHistory.findMany({
        where: { sourceTrxId },
        orderBy: { createdAt: "desc" },
        with: { user: true },
      });
    },
  })
);

An error:

ERR 21 |     var _builder_options_drizzle_skipDeferredFragments;
22 |     return {
23 |         skipDeferredFragments: (_builder_options_drizzle_skipDeferredFragments = builder.options.drizzle.skipDeferredFragments) !== null && _builder_options_drizzle_skipDeferredFragments !== void 0 ? _builder_options_drizzle_skipDeferredFragments : true,
24 |         columnToTsName: (column) => {
25 |             if (!column.uniqueName) {
26 |                 throw new Error(`Column ${String(column.name)} has no uniqueName`);
                               ^
GraphQLError: Internal server error
       path: [ "trxMap_history", 1, "user" ],
  locations: [
  [Object ...]
],
 extensions: {
  code: "ERR_INTERNAL_SERVER",
  unexpected: true,
},

      at columnToTsName (/node_modules/@pothos/plugin-drizzle/esm/utils/config.js:26:27)
      at selectionToQuery (/node_modules/@pothos/plugin-drizzle/esm/utils/selections.js:121:35)
      at getSelection (/node_modules/@pothos/plugin-drizzle/esm/model-loader.js:62:25)
      at loadSelection (/node_modules/@pothos/plugin-drizzle/esm/model-loader.js:88:48)
      at loadSelection (/node_modules/@pothos/plugin-drizzle/esm/model-loader.js:88:30)
      at /node_modules/@pothos/plugin-drizzle/esm/index.js:136:41
      at middleware (/node_modules/graphql-shield/esm/generator.js:46:18)
      at processTicksAndRejections (native:7:39)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions