Coder Social home page Coder Social logo

prisma list of enums TS bug about pothos HOT 6 CLOSED

SpeedySH avatar SpeedySH commented on August 16, 2024
prisma list of enums TS bug

from pothos.

Comments (6)

hayes avatar hayes commented on August 16, 2024 1

Thanks for the report, I'll try to get this fixed in the next day or so.

In the mean time, this should also work:

import {  Environment,} from "@prisma/client"; // it is native enum

const EnvironmentEnum = builder.enumType(Environment, { name: "Environment" });

const EnvironmentVariableCreateInput = builder.prismaCreate("EnvironmentVariable", {
  name: "EnvironmentVariableCreateInput",
  fields: (t) => ({
    key: t.string(),
    value: t.string(),
    isSensitive: t.boolean(),
    environments: t.field({ type: [EnvironmentEnum] }),
  }),
});

from pothos.

hayes avatar hayes commented on August 16, 2024 1

I think the issue is in the Prisma utils plugin, I think it just doesn't handle array columns, but that shouldn't be too hard to fix

from pothos.

SpeedySH avatar SpeedySH commented on August 16, 2024

Thanks for the report, I'll try to get this fixed in the next day or so.

In the mean time, this should also work:

import {  Environment,} from "@prisma/client"; // it is native enum

const EnvironmentEnum = builder.enumType(Environment, { name: "Environment" });

const EnvironmentVariableCreateInput = builder.prismaCreate("EnvironmentVariable", {
  name: "EnvironmentVariableCreateInput",
  fields: (t) => ({
    key: t.string(),
    value: t.string(),
    isSensitive: t.boolean(),
    environments: t.field({ type: [EnvironmentEnum] }),
  }),
});

I tried to do the same, following the examples in the documentation. Exactly the same TS error :(

Thanks, waiting for a fix, will put @ts-ignore up in the meantime

from pothos.

hayes avatar hayes commented on August 16, 2024

I think I misunderstood the issue, it looks like it's expecting a single Environment rather than a list, I'll try to figure out what's going on with that

from pothos.

SpeedySH avatar SpeedySH commented on August 16, 2024

I think I misunderstood the issue, it looks like it's expecting a single Environment rather than a list, I'll try to figure out what's going on with that

The dilemma here is that I have tried all the ways to declare the list as a field where only enum values are expected. None of them allows to do it without an error, at the current stage.

Thanks anyway

from pothos.

hayes avatar hayes commented on August 16, 2024

should be fixed in the latest release

from pothos.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.