graphql-nexus / nexus-plugin-prisma

Deprecated
MIT License
828 stars 118 forks source link

Use Prisma Type as arg #1030

Open chrishoermann opened 3 years ago

chrishoermann commented 3 years ago

kind of similar to graphql-nexus/nexus#69 but there where some major changes since then so I don't know if commenting on this issue makes sense.

My question: Is it possible to use a type from the Prisma namespace as argument type like:

 t.field("createCompany", {
      type: "Company",
      args: {
        secret: nonNull(stringArg()), // SOME OTHER ARGS
        data: arg({ type: Prisma.CompanyCreateInput }), // USE PRISMA TYPE AS ARG
      },
      async resolve( _root, args, ctx ) {
        //... logic
      }
    });

the error states that Property 'CompanyCreateInput' does not exist on type 'typeof Prisma' but the type CompanyCreateInput is definitely exported in the index.d.ts of .prisma/client.

fnky commented 3 years ago

I have similar question, but not quite. I am fine being able to access them through a string, my only issue is that there aren't enough field types available.

For example, only the ModelWhereUniqueInput is generated, but not ModelWhereInput, which would allow me to implement a custom "where" field without the need to create a custom Input and miss out on the advanced filtering.

I think at least all aggregate fields (from ModelAggregateArgs) should be generated.

durga14341 commented 1 year ago

Any Update on this issue?