question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

List types with union input types are not supported

See original GitHub issue

Bug description

I’m submitting this as a bug report since I can’t find anything in the docs about this limitation, I apologize in case I’m missing something.

I got this in my schema.prisma:

enum UserRole {
  ADMIN
  // ...
}

model User {
  roles UserRole[]
  // ...
}

Since this syntax is allowed and prisma client is correctly generated I expected I could query my User table on the roles column with the following syntax:

import { UserRole } from '@prisma/client';

const users = await prisma.user.findMany({
  where: {
    roles: [UserRole.ADMIN],
  },
});

But if try to do so I get the following error:

List types with union input types are not supported

Expected behavior

Since the Prisma schema parser allows the enum list syntax and the client is correctly generated I would expect this to work, or at least a note in the docs.

Environment & setup

  • OS: macOS
  • Database: PostgreSQL
  • Node.js version: v12.13.1
  • Prisma version:
@prisma/cli          : 2.7.0
Current platform     : darwin
Query Engine         : query-engine eaade828a21d8ee3f4940f0af7da3ae0922db4df (at node_modules/@prisma/cli/query-engine-darwin)
Migration Engine     : migration-engine-cli eaade828a21d8ee3f4940f0af7da3ae0922db4df (at node_modules/@prisma/cli/migration-engine-darwin)
Introspection Engine : introspection-core eaade828a21d8ee3f4940f0af7da3ae0922db4df (at node_modules/@prisma/cli/introspection-engine-darwin)
Format Binary        : prisma-fmt eaade828a21d8ee3f4940f0af7da3ae0922db4df (at node_modules/@prisma/cli/prisma-fmt-darwin)
Studio               : 0.287.0
Preview Features     : insensitiveFilters

Anyway, congratulations and thank you for the amazing work with this project.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

9reactions
calummoorecommented, Sep 29, 2020

Sorry, yes - I hadn’t upgraded the client. That’s now working - thanks!

Just need to wait for #3475 now, as exact equals on an array of strings is not very useful.

1reaction
calummoorecommented, Sep 28, 2020

I’m running into the same error (List types with union input types are not supported) with the following model and query:

model Account {
  id         String          @default(dbgenerated()) @id
  scopes     String[]
}
await prisma.account.findMany({
  where: { scopes: ['abc'] },
}),

I tried upgrading to 2.8-dev.55 (and 2.8-dev.36), but I get the following error when generating types (prisma generate).

Error:
TypeError: Cannot read property '0' of undefined
    at DMMFClass.resolveInputTypes (/Users/calummoore/snapboard/code/packages/api/node_modules/@prisma/client/generator-build/index.js:9943:39)
    at new DMMFClass (/Users/calummoore/snapboard/code/packages/api/node_modules/@prisma/client/generator-build/index.js:9922:10)
    at new TSClient (/Users/calummoore/snapboard/code/packages/api/node_modules/@prisma/client/generator-build/index.js:10321:17)
    at buildClient (/Users/calummoore/snapboard/code/packages/api/node_modules/@prisma/client/generator-build/index.js:11411:18)
    at generateClient (/Users/calummoore/snapboard/code/packages/api/node_modules/@prisma/client/generator-build/index.js:11466:45)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)

And the following runtime error (although given I wasn’t able to run prisma generate because of the above error, it’s probably related to that).

/Users/calummoore/snapboard/code/packages/api/node_modules/@prisma/client/runtime/src/runtime/dmmf.ts:74
        const first = field.inputTypes[0].type
                            ^
TypeError: Cannot read property '0' of undefined
    at mr.resolveInputTypes (/Users/calummoore/snapboard/code/packages/api/node_modules/@prisma/client/runtime/src/runtime/dmmf.ts:74:29)
    at new mr (/Users/calummoore/snapboard/code/packages/api/node_modules/@prisma/client/runtime/src/runtime/dmmf.ts:35:10)
    at new t (/Users/calummoore/snapboard/code/packages/api/node_modules/@prisma/client/runtime/src/runtime/getPrismaClient.ts:310:20)
    at Object.<anonymous> (/Users/calummoore/snapboard/code/packages/api/src/db/prisma.ts:3:16)
    at Module._compile (internal/modules/cjs/loader.js:1158:30)
    at babelWatchLoader (/Users/calummoore/snapboard/code/node_modules/babel-watch/runner.js:51:13)
    at Object.require.extensions.<computed> [as .ts] (/Users/calummoore/snapboard/code/node_modules/babel-watch/runner.js:62:7)
    at Module.load (internal/modules/cjs/loader.js:1002:32)
    at Function.Module._load (internal/modules/cjs/loader.js:901:14)
    at Module.require (internal/modules/cjs/loader.js:1044:19)
Read more comments on GitHub >

github_iconTop Results From Across the Web

List types with union input types are not supported #3691
I'm submitting this as a bug report since I can't find anything in the docs about this limitation, I apologize in case I'm...
Read more >
Unions and interfaces - Apollo GraphQL Docs
Unions and interfaces are abstract GraphQL types that enable a schema field to return one of multiple object types. Union type.
Read more >
GraphQL Union and Input Type? - Stack Overflow
As of September 2017, this is not possible. There is an ongoing discussion ... As Artur mentioned, support for union input types is...
Read more >
Absinthe middleware for tagged union input types
At the time of writing this, union input types are not yet supported by either Absinthe or the GraphQL spec itself.
Read more >
Union types in GraphQL - Dev - Discuss Dgraph
The member types of a Union type must all be Object base types; Scalar, Interface and Union types must not be member types...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found