https://www.prisma.io/ logo
Join SlackCommunities
Powered by
# graphql-nexus
  • b

    BRob

    04/28/2021, 11:25 PM
    Cancel that, this was my fault ^
  • a

    Adam

    05/03/2021, 2:35 PM
    I'm trying to remove the
    nexus-plugin-prisma
    (we held out seeing if the new functionality would be ready by Q2) How should the
    SortOrder
    be defined? I'm following the guide here (https://nexusjs.org/docs/plugins/prisma/removing-the-nexus-plugin-prisma) but the docs don't seem to be correct. For example if you follow it and do
    Copy code
    const SortOrder = enumType({
      name: 'SortOrder',
      members: ['asc', 'desc'],
    })
    
    const PostOrderByInput = inputObjectType({
      name: 'PostOrderByInput',
      definition(t) {
        t.field('title', {
          type: 'SortOrder',
        })
      },
    })
    
    const User = objectType({
      name: 'User',
      definition(t) {
        <http://t.nonNull.int|t.nonNull.int>('id')
        t.string('name')
        t.nonNull.list.nonNull.field('posts', {
          type: 'Post',
          args: {
            cursor: arg({ type: 'PostWhereUniqueInput' }),
            take: intArg(),
            skip: intArg(),
            orderBy: arg({ type: 'PostOrderByInput' }),
            where: arg({ type: 'PostWhereInput' }),
          },
          resolve: (parent, args, context) => {
            return context.prisma.user
              .findUnique({
                where: { id: parent.id },
              })
              .posts({
                cursor: args.cursor || undefined,
                take: args.take || undefined,
                skip: args.skip || undefined,
                orderBy: args.orderBy || undefined,
                where: {
                  id: args.where?.id || undefined,
                  title: args.where?.title || undefined
                },
              })
          },
        })
      },
    })
    It gives you an error because `prisma`'s
    orderBy
    cannot take null | undefined fields, and the orderByInput is optional for each field of the object
    Copy code
    Types of property 'id' are incompatible.
            Type 'SortOrder | null | undefined' is not assignable to type 'SortOrder | undefined'.
              Type 'null' is not assignable to type 'SortOrder | undefined'.ts(2322)
    Is there a more concise way of typing this rather than making a new object with explicitly non-null fields?
    j
    b
    • 3
    • 7
  • r

    Robert Witchell

    05/04/2021, 10:47 AM
    can someone explain to me how I can use the prisma generated type in my resolver?
    Copy code
    t.nonNull.field('createUserViaUserDetail', {
          type: 'UserDetail',
          args: arg({
            type: 'UserDetailUncheckedCreateInput',
          }),
          resolve: async (parent, { data }, { prisma, userId }, info) => {
            return prisma.userDetail.create({ data })
          },
        })
    [ERROR]:
    - Missing type undefined, did you forget to import a type to the root query?
    - Missing type UserDetailUncheckedCreateInput, did you forget to import a type to the root
    • 1
    • 3
  • a

    Akshay Kadam (A2K)

    05/06/2021, 1:26 PM
    When I use
    nonNull
    in
    args
    in
    nexus
    , does it mean that the input is required? Or it's just not equal to
    null
    ?
    Copy code
    export const Query = queryType({
      definition(t) {
        t.nonNull.list.field('getAcquisitionsByPrice', {
          type: 'Acquisition',
          args: {
            minPrice: nonNull(arg({ type: 'BigInt' })),
            maxPrice: nonNull(arg({ type: 'BigInt' })),
          },
    Also, how do I set a field to be optional in
    nexus
    args?
    d
    r
    • 3
    • 10
  • m

    Milan

    05/08/2021, 4:55 AM
    Hi
  • m

    Milan

    05/08/2021, 4:56 AM
    How would you define a json field in nexus? I don't want to define an object for it as it isn't very concrete type
    r
    • 2
    • 2
  • p

    Philipp Humburg

    05/18/2021, 9:08 PM
    Hey guys when I have a InputType with optional fields in it, then the prisma.modeltype.create Shows me Type Not matching, is there a way to get proper ts Support for That
    c
    • 2
    • 4
  • d

    Daniel Esteves

    05/22/2021, 11:19 PM
    Is there any way to remove fields from generated input? I want to remove the
    user
    and
    userId
    fields from that input
    m
    • 2
    • 1
  • p

    Philipp Humburg

    05/24/2021, 8:34 PM
    Is there a working example for graphql nexus + prisma + relay backend and frontend?
  • т

    Тоше

    05/26/2021, 7:37 AM
    How do u handle aggregation inside graphql-nexus models to avoid the N+1 problem. • Model User linked with a relation to a model UserDetail • tested it with orderBy instead of aggregate, it still resolves it as a seperate sql query
    Copy code
    export const UsersAvgAge = extendType({
      type: 'User',
      definition(t) {
        t.field('aggregate', {
          type: 'AggregateUser',
          resolve(_parent, args, { prisma }, info) {
            const select = new PrismaSelect(info).value
            return prisma?.useDetail?.aggregate({
              where: { id: { equals: _parent.id } },
              ...select,
            })
          },
        })
      },
    })
  • k

    Kevin Serrano

    05/27/2021, 6:59 AM
    Any leads on what I'm doing wrong in using the dateTime scalar in nexus from nexus-prisma?
    Copy code
    TSError: ⨯ Unable to compile TypeScript:
    src/modules/ProjectOwner.ts:11:7 - error TS2339: Property 'dateTime' does not exist on type 'ObjectDefinitionBlock<"ProjectOwner">'.
    
    11     t.dateTime(PO.createdAt.name, PO.createdAt)
    The makeSchema looks like this:
    Copy code
    import NexusPrismaScalars from 'nexus-prisma/scalars'
    import { makeSchema } from 'nexus'
    
    import * as types from './modules/types'
    
    export const schema = applyMiddleware(
      makeSchema({
        types: {
          ...types,
          ...NexusPrismaScalars
        },
    ...
    r
    • 2
    • 11
  • m

    Marcus

    05/27/2021, 12:44 PM
    Is there a place to change the where input types by hand in crud? I wan't to support all the old filters with
    @prisma/binding-argument-transform
    but I need to generate other input types. Instead of IntFilter, StringFilter,... I need field_startsWith, field_contains,... (primsa1 API) Doing it by hand works, but the project is too big to do it at all places. I could find the right spot in the plugin source code to handle the other input filter. Does anyone know how to do this? All ideas are welcome.
    d
    • 2
    • 2
  • k

    Kevin Serrano

    05/28/2021, 1:39 AM
    Hi, so I have a code snippet here that has part of the resolve function for a mutation. The key here is that I'm calling on
    ctx.db
    for my Prisma Client. With just the
    data
    property on the select, the resolver works fine, but as soon as I add the
    select
    property, typescript starts freaking out. It stops freaking out if I manually add every single property that exists on a projectOwner that's exposed on nexus. However, it's weird because the resolver isn't even expecting a projectOwner--it's just an intermediary in order to construct tokens, which is seen in the return. Any ideas why it's freaking out like this for subsets?
    Untitled.js
    d
    • 2
    • 1
  • m

    Mikastark

    05/31/2021, 8:22 AM
    Hello everyone 🙂 Does anyone encounter such error ?

    https://user-images.githubusercontent.com/23034761/120086933-db0b6b80-c0e3-11eb-9f2f-732ff9c5514c.png▾

    It seems prisma doesn't like nullish where/orderBy nested values 😕. I would like to simply pass all my gql args directly to prisma (
    return context.prisma.posts.findMany(args)
    )
    r
    • 2
    • 16
  • d

    David Panart

    06/22/2021, 10:58 AM
    Hello here, glad to have joined that slack 🙂 A quick question, I haven't found a clear answer yet : Does Prisma have somehow the possibity to generate the GraphQL API from it's client / schema ? Somehow like
    <https://www.kaviarjs.com/>
    do ? That's an incredible feature
    r
    • 2
    • 1
  • v

    Vincent

    06/22/2021, 12:45 PM
    Hello everyone, new to prisma and nexus graphql, and I try to figure out why I’m having this error with the following code :
    Copy code
    Type '1 | 2 | 3' is not assignable to type 'RoleCreateNestedOneWithoutUserInput | undefined'.
      Type '1' is not assignable to type 'RoleCreateNestedOneWithoutUserInput | undefined'.ts(2322)
    index.d.ts(2682, 5): The expected type comes from property 'role' which is declared here on type 'UserCreateInput'
    (property) role?: Prisma.RoleCreateNestedOneWithoutUserInput | undefined
    Thank you for your answers.
    r
    • 2
    • 5
  • d

    divyendu

    06/23/2021, 9:05 AM
    Hello everyone, What is the biggest example of nexus in production? (public code-base)
  • c

    chrisdrackett

    06/30/2021, 11:47 PM
    anyone using nexus on heroku? I’m trying to use
    shouldExitAfterGenerateArtifacts
    but it does not seem to be working
  • c

    chrisdrackett

    06/30/2021, 11:58 PM
    I’ve tried a couple things, but it never seems to exit after building out the types
    r
    • 2
    • 8
  • c

    Christian Villamin

    07/02/2021, 6:00 PM
    Does using Nexus in NestJS make sense? I've tried it, it works but it doesn't feel right... Normally, I just go Apollo Server + Nexus + Prisma. I tried replacing Apollo Server with NestJS and using its architecture but yeah... feels really weird and just convoluting..? I could be just misinformed. Can anyone give advice?
    d
    • 2
    • 5
  • k

    Kerim Hudson

    07/05/2021, 3:43 PM
    Hey all. We’re in the process of upgrading from Prisma 1 to Prisma 2, and noticed the deprecation of nexus-plugin-prisma whilst waiting for nexus-prisma. Was kind of wondering what others are doing around this right now? I’ve seen some comments of going just vanilla nexus, but was curious to see other thoughts on how this could be best tackled?
    l
    d
    l
    • 4
    • 9
  • c

    Christian Villamin

    07/13/2021, 7:25 AM
    Hello, how to fix this? If I use ts-node-dev --transpile-only like in tuts, it's ok. But in production, I will build using TSC command from typescript. But it get this error.... I'm using nexus-prisma plugin to streamline my things with prisma schema being the single source of truth. edit: i know nexus-prisma is not for production stuff, but to clarify this is just some personal learning project thing
    r
    • 2
    • 8
  • т

    Тоше

    07/23/2021, 7:45 AM
    We have an issue with performance for our Apollo-server-express/prisma 2/graphql-nexus/graphql-shield server, depending on our test server it bottlenecks severely compared to our prexisting php-fpm servers: • on a 4 core 4 thread cpu it bottle necks at around 50 parallel requests per second, from the logs it looks like its cpu wait time. Which is severe degradation compared to our old infra • we also conducted tests at a 32 core 32 thread dedicated cpu and is performing bit better at around for 600 parallel requests per second , but still worse than old infrastructure. Are this performance levels common with prisma or are there any tips/advices that we can take to improve it, so far we tried dropping Apollo server express for mercurial and removing the permissions middleware's for testing purposes. But from the looks of it the bottleneck seems prisma. Willing to share a bit more info regarding the stack, tests conducted in a dm with prisma employee for them to try to replicate the issue
    r
    d
    • 3
    • 13
  • l

    ludovic

    07/25/2021, 7:42 PM
    Hello everyone, I am working with the nexus framework, I created my objectType ‘Order’ and try to map the data that I want to expose from my prisma schema. Here the field createdAt. In my prisma schema, it is like that : createdAt DateTime @default(now())) In my objectType, if I just write ’t.nonNull.date(“createdAt”), the field createdAt will be available in the parent arg (the first param in the resolve function) of the objectType, but if I try to implement it with my own resolve method, it will not be available anymore. My goal is to modify the createdAt value when the field is asked in graphql. Is there a way to do that ? thanks
    r
    n
    • 3
    • 4
  • r

    Rostislav Simonik

    07/29/2021, 6:24 AM
    Hello, i know that topic is long term one, but wanna check, because wasn’t able to find some recent resolution. • R1: We know that graphql doesn’t differentiate between nullability and optionality • R2: We had a time ago required and nullable attributes in nexus • R3: Currently we have only nonNull or nullable specifiers The unnecessary boilerplate difficulty i’m observing is when I have prisma update, obviously prisma upsert as well (contains update within). • all attributes must be nullable on outer schema due R1 • but i’d like internally ensure mandatory value, even it’s optional on prisma schema So it would be great to differentiate on nexus level some kind of validation whether attributes has null or undefined values. like
    Copy code
    const SomeInput = inputObjectType({
      name: 'SomeInput',
      definition(t) {
        t.nonNull.optional.string('some') /// that would autogenerate runtime validation so given value can be undefined but not null 
      }
    })
    is there any plan to do so, or existing solution how to address this without writing unnecessary boilerplate code ? thx for info.
    r
    • 2
    • 8
  • m

    Michael

    08/05/2021, 10:28 PM
    I generated a massive schema.graphql file with nexus from a large data base, and now when I use
    next dev
    webpack is installing all the code I dont need and crashing it. Anyone have any ideas on how to fix this?
  • m

    Michael

    08/05/2021, 10:29 PM
    Copy code
    /***/ "./src/server/graphql/BranchCode/queries/index.ts":
    /*!********************************************************!*\
      !*** ./src/server/graphql/BranchCode/queries/index.ts ***!
      \********************************************************/
    /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  • m

    Michael

    08/05/2021, 10:29 PM
    there are like hundreds of these in the webpack bundle
  • m

    Michael

    08/06/2021, 8:57 PM
    my nexus schema is just absolutely massive due to large prisma schema, is there anyway I can reduce its size
    r
    • 2
    • 1
  • m

    Michael

    08/06/2021, 8:58 PM
1...2122232425Latest