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

    Awey

    10/30/2020, 6:11 PM
    Is this not a valid way to set args?
    Copy code
    args: {
            data: {
              text: stringArg({ required: true }),
            },
          },
    r
    r
    • 3
    • 5
  • o

    Oliver Evans

    10/30/2020, 7:45 PM
    Hi, I'm using nexus & the prisma 2 plugin - I'm wondering if it's possible to access the contents of
    schema.prisma
    from nexus to programmatically expose my types. Specifically, if I have the following in `schema.prisma`:
    Copy code
    model Person {
      name String
      age Int
    }
    I would like to construct the following javascript object:
    Copy code
    {
      name: "String",
      age: "Int"
    }
    Thanks!
    r
    • 2
    • 2
  • a

    Awey

    10/30/2020, 9:23 PM
    Why can't something both be marked as
    nullable: false
    and
    required: false
    ??? I have two required fields in my schema one of type string the other boolean. But when updating, I want to something like this. If I only set
    nullable: false
    then when I go to call my update mutation it asks me to pass in the other fields to update. What if I only want to update one field? And if I set
    required: false
    my types become messed up and I'm told I can't update data where the value could possibly be
    null
    r
    • 2
    • 4
  • d

    Dave

    10/31/2020, 11:01 AM
    I was wondering if someone could help me with a "nexus-plugin-prisma" problem. I have multiple databases so have setup multiple prisma schemas which output seperately (e.g.
    generator client {
    provider        = "prisma-client-js"
    output          = "../db/prisma1"
    previewFeatures = ["microsoftSqlServer"]
    }
    ), I then try to run makeSchema like below:
    const schema = makeSchema({
    types: {
    ...types,
    Query,
    Mutation,
    },
    plugins: [nexusPrisma({})],
    outputs: {
    schema: __dirname + '/../schema.graphql',
    typegen: __dirname + '/generated/nexus.ts'
    },
    typegenAutoConfig: {
    contextType: 'ContextModule.Context',
    sources: [
    {
    source: require.resolve(__dirname + '/../db/prisma1/index.d.ts'),
    alias: 'prisma1'
    },
    {
    source: require.resolve(__dirname + '/../db/prisma2/index.d.ts'),
    alias: 'prisma2'
    },
    {
    source: require.resolve(__dirname + '/../db/prisma3/index.d.ts'),
    alias: 'prisma3'
    },
    {
    source: require.resolve('./context'),
    alias: 'ContextModule'
    }
    ]
    }
    })
    However it doesn't seem to be able to resolve any of the prisma clients and I get the following error
    Error: You most likely forgot to initialize the Prisma Client.
    r
    • 2
    • 1
  • o

    Oliver Evans

    11/01/2020, 6:02 PM
    Has anyone attempted GraphQL interfaces with prisma + nexus? Something like https://itnext.io/graphql-interfaces-and-union-types-with-prisma-and-yoga-7224f9e1d9ad
    s
    • 2
    • 2
  • s

    Swapnull

    11/03/2020, 1:29 PM
    Does anybody have an example of using
    nexus-plugin-shield
    with
    @nexus/schema
    ? I can only find nexus framework examples with
    use
    .
    r
    s
    r
    • 4
    • 8
  • s

    Swapnull

    11/03/2020, 5:15 PM
    I have been using
    t.list.json
    with the nexus framework but it doesn't seem to exist now I have switch to
    @nexus/schema
    . Does anybody know what an alternative of this would be?
    s
    • 2
    • 8
  • j

    Jonathan

    11/03/2020, 7:10 PM
    Im gonna ask a newbish question, but does anyone else have relatievly slow startup times when it comes to starting up their Express server? Using dev servers (Nodemon), it may take something like 20-30 seconds for each restart to get the server up and running. I somewhat wonder if it may have to do with the generation of the
    nexus/schema
    (
    _shouldGenerateArtifacts_: _true_,
    ), but I cant be too certain if it is related. Anyone ever dealt with debugging startup times?
    s
    r
    • 3
    • 6
  • s

    Shreyas Sreenivas

    11/04/2020, 5:17 AM
    Has anyone else faced a problem when trying to use the connection plugin in the definition of an
    interfaceType
    ? I get
    Type Error: t.connectionField is not a function
    when trying to do so
  • a

    Ahmar Suhail

    11/04/2020, 2:17 PM
    Hey guys, quick question: with the framework before, we would run nexus reflect and it would update the SDL whenever we created a new type. now we have to create our own reflect command like this. Just wondering if we have to run this command every time we create a new type, or if there is a way to watch and for it to update automatically?
    r
    • 2
    • 2
  • s

    Swapnull

    11/04/2020, 2:34 PM
    Hey everybody 🙂 We are having some performance issues with prisma and nexus. We use postgres as the database but we are finding very simple requests like
    users(first: 5) { uuid }
    which just has
    t.crud.users()
    can take 3 - 7 seconds. We are using vercel serverless to deploy an Apollo Server. What have people done to improve performance as this could end up a huge barrier.
    r
    j
    • 3
    • 10
  • m

    Matheus Assis

    11/05/2020, 2:38 PM
    Using
    prisma plugin
    , why is the "array" queries allow for more filtering instead of only filtering by the indexes, where as the "single" queries do not. Is there something I can do, a setting, on either nexus schema, plugin prisma or prisma itself to allow that? Look at how the people query allow for more filtering, where the person does not
    r
    • 2
    • 5
  • b

    Ben Chen

    11/05/2020, 10:38 PM
    Hey folks, I’m using
    nexus-plugin-prisma
    and trying to use
    IntFilter
    and
    StringFilter
    without
    crud
    .
  • b

    Ben Chen

    11/05/2020, 10:39 PM
    However, when I try to run
    prisma generate
    it says it can’t find
    IntFilter
    and
    StringFilter
    . This historically has worked when we used
    crud
    . How can I leverage prisma client’s filtering methods?
    r
    m
    • 3
    • 5
  • d

    Dan Borstelmann

    11/06/2020, 1:35 AM
    Hi folks, when querying nested objects, Nexus-Prisma seems to pull the related models out of prisma itself rather than allowing you to populate it yourself. Does anyone have any info on how this behavior works? I can't find any docs. Here is an example of what I mean:
    Copy code
    export const User = objectType({
      name: 'User',
      definition(t) {
        t.model.id();
        t.model.email();
        t.model.handle();
      },
    });
    
    export const Follow = objectType({
      name: 'Follow',
      definition(t) {
        t.model.id();
        t.model.createdAt();
        t.model.follower(); // This is a user
        t.model.following(); // This is a user
      },
    });
    
    export const FollowQuery = extendType({
      type: 'Query',
      definition(t) {
        t.list.field('followers', {
          type: 'Follows',
          resolve: async (_parent, args, context) => {
            const authedId = getUserId(context);
    
            let followers;
            try {
              followers = await context.prisma.follow.findMany({
                where: { following: { id: authedId } },
                select: {
                  id: true,
                  follower: {
                    // THIS SELECT IS IGNORED. <-------------
                    // User model is populated with all fields (including say the email we don't want to expose)
                    select: {
                      handle: true
                    },
                  },
                },
              });
            } catch {
              throw new Error();
            }
    
            return followers;
          },
        });
      },
    });
    
    query followers {
      followers {
        id
        follower {
          handle
          # if I ask for email here it will return the email even though it wasn't selected
        }
      }
    }
    r
    i
    • 3
    • 8
  • d

    Darryl

    11/06/2020, 9:28 AM
    I’m trying to update
    @prisma/client
    and
    @prisma/cli
    but I’m getting the following warning related to
    nexus-plugin-prisma
    . Should I just abandon the update for now or can somebody tell me what the possible undefined behaviours and bugs could be?
    Copy code
    Warning: nexus-plugin-prisma@0.23.1 does not support @prisma/client@2.10.2. The supported range is: `2.10.0`. This could lead to undefined behaviors and bugs.
    I noticed that
    nexus-plugin-prisma
    has
    @prisma/client
    as a dependency pinned to the specific
    2.1.0
    version and since its last release there’ve been two Prisma patches. It also has had PRs bumping this to
    2.10.1
    and now
    2.10.2
    but they’ve haven’t been merged.
    s
    r
    • 3
    • 3
  • l

    leonardodino

    11/08/2020, 6:05 PM
    hey there! I’ve just migrated a project from
    nexus
    framework to
    @nexus/schema
    . 🙌 I’m working with Relay on the frontend, and I wonder if global identification is still something that we consider implementing at the schema level. nexus is aware of the types, and already has the
    t.id
    , but it’s only a identity function. I think it could wrap into global id, and unwrap them in the resolvers so we can pass it directly to tools like prisma (or other tools/systems/etc 😄)
    • 1
    • 1
  • a

    Adam

    11/09/2020, 4:03 AM
    Is there a good way to set up a build process for
    makeSchema
    when using typescript? All the types aren't generated until you run it, meaning the build will always output errors unless you've built it previously
    r
    • 2
    • 1
  • p

    Paul Hendrickson

    11/09/2020, 6:42 PM
    I’m dockerizing my nexus prisma app, but when I run
    tsc
    inside my Docker container I get
    Copy code
    Cannot find name ‘NexusPrisma’
    Any ideas?
    r
    • 2
    • 2
  • p

    Peter

    11/10/2020, 3:29 PM
    Hi What is the best way to create pisma crud query with optional args? I have something like this
    Copy code
    extendType({
      type: 'Query',
      definition(t) {
        t.list.field('bts', {
          type: 'Bts',
          args: {
            minLat: floatArg({
              default: 0,
              required: true,
            }),
            maxLat: floatArg({
              default: 0,
              required: true,
            }),
            minLong: floatArg({
              default: 0,
              required: true,
            }),
            maxLong: floatArg({
              default: 0,
              required: true,
            }),
          },
          resolve(_root, { minLat, maxLat, minLong, maxLong }, ctx) {
            return ctx.prisma.bts.findMany({
              where: {
                latitude: {
                  gte: minLat,
                  lte: maxLat,
                },
                longitude: {
                  gte: minLong,
                  lte: maxLong,
                },
              },
            })
          },
        })
    But when I delete required I get error
    Copy code
    Type 'number | null | undefined' is not assignable to type 'number | undefined'.
      Type 'null' is not assignable to type 'number | undefined'
    So what is the best way to handle that optional args?
    a
    l
    r
    • 4
    • 11
  • p

    Paul Hendrickson

    11/11/2020, 4:47 PM
    I see that by default, all fields that you define in your Nexus object model are exposed. Is there anyway to not have all models exposed? I’m using the t.model to combine multiple fields in my Prisma model to output it as one field in graphql
    Copy code
    const customer = objectType({
      name: “customer”,
      definition(t) {
        t.model.addressLine1
        t.model.addressLine2
        t.field(“address”, {
          type: “string”,
          resolve: (root) => root.addressLine1 + root.addressLine2
        }
      }
    });
    and I don’t want the graphql to have “addressLine1” and “addressLine2” because it’s unnecessary.
    👍 1
    b
    l
    • 3
    • 3
  • d

    Dan Borstelmann

    11/13/2020, 9:41 AM
    Does anyone know how to add __typename info to prisma nested data? I'm using Pusher instead of subscriptions because of serverless and when I pass prisma data to pusher it does not come with the __typename which messes up my ability to update the apollo cache with the new data. I can manually add __typename to the data but it's nested data and that seems sketchy so I'd rather just use whatever graphql is using when it returns to tag it with the __typename. This must exist in some function?
  • l

    Lennard Westerveld

    11/16/2020, 6:45 PM
    Solved see ticket Does anyone know how to override FieldResolver in typescript? Because i want to change FieldResolver because it don't support function fields that returning the value. For example i have the following typing
    Copy code
    objectType({
      name: 'TestQuery',
      definition(t) {
        t.field('hello', {type: 'String'});
        t.field('hello2', {type: 'String'});
      },
    }),
    extendType({
      type: 'Query',
      definition(t) {
        t.field('test', {
          type: 'TestQuery',
          resolve: () => ({
            hello: () => ... function that returns promise<String>,
            hello2: () => ... function that returns promise<String>,
          }),
        });
      },
    }),
    Gives the following Message
    Copy code
    Error:(73, 13) TS2322: Type '() => Promise<string>' is not assignable to type 'string'.
    l
    • 2
    • 2
  • l

    Lennard Westerveld

    11/16/2020, 8:08 PM
    I have also created a sandbox: https://codesandbox.io/s/sandbox-nexus-promise-error-3ddfq?file=/src/schema.ts with an example how i modeld my datamodels in classes remove the ts-ignore in schema.ts to see the errors! also opened ticket: https://github.com/graphql-nexus/nexus-plugin-prisma/issues/958 Solved see ticket
    👍 1
    ✔️ 1
  • j

    jasonkuhrt

    11/16/2020, 8:22 PM
    https://twitter.com/JasonKuhrt/status/1328432459755741185
    node parrot 1
    💯 4
    👍 4
    graphql 2
  • a

    andreas

    11/18/2020, 12:48 PM
    From a @nexus/schema / nexus-plugin-prisma standpoint, what is a recommended way to do field level authorisation / permission checks? Field authorize plugin, graphql-shield, other? I’m in the process of upgrading a project to prisma 2, latest nexus etc and are coming from an older nexus setup where we’re using graphql-shield in combination with graphql-middleware to do this today. With the breaking changes in nexus@0.16 of upgrading to graphql@15 I’m getting peer dependency warnings about graphql from graphql-middleware (running the latest version). There is an issue created back in April about graphql@15 support for graphql-middleware (https://github.com/prisma-labs/graphql-middleware/issues/254) with not much info on whether this is planned to be addressed with or not.  So far things seems to work for me regardless of this warning but given that its not yet supported by graphql-middleware I’d like to collect some info on whether I should look at some other authorisation solution to replace graphql-shield. Any input here that would help me decide the way forward is appreciated 🙂
    r
    l
    d
    • 4
    • 8
  • p

    Paul Hendrickson

    11/24/2020, 2:23 PM
    With the experimentalCRUD plugin is there a way to set default configurations? I see you can set a resolver for it, but that kinda overrides everything, right? I want to set a default of 100 records returned if no “first” or “last” is designated, but keep everything else the same.
    r
    • 2
    • 2
  • a

    Adam

    11/24/2020, 3:19 PM
    Updated to the latest
    nexus-plugin-prisma@0.24.0
    and running
    makeSchema
    is now giving me the error
    Copy code
    nexus-plugin-prisma/src/dmmf/transformer.ts:55
        inputTypes: schema.inputTypes.map((type) => transformInputType(type, globallyComputedInputs, atomicOperations)),
                                      ^
    TypeError: Cannot read property 'map' of undefined
        at transformSchema (node_modules/nexus-plugin-prisma/src/dmmf/transformer.ts:55:35)
        at transform (node_modules/nexus-plugin-prisma/src/dmmf/transformer.ts:30:13)
        at Object.exports.getTransformedDmmf (node_modules/nexus-plugin-prisma/src/dmmf/transformer.ts:17:37)
        at new SchemaBuilder (node_modules/nexus-plugin-prisma/src/builder.ts:267:7)
        at Object.build (node_modules/nexus-plugin-prisma/src/builder.ts:185:19)
        at Object.onInstall (node_modules/nexus-plugin-prisma/src/plugin.ts:46:62)
        at node_modules/@nexus/schema/src/builder.ts:663:44
        at Array.forEach (<anonymous>)
        at SchemaBuilder.beforeWalkTypes (node_modules/@nexus/schema/src/builder.ts:657:18)
        at SchemaBuilder.getFinalTypeMap (node_modules/@nexus/schema/src/builder.ts:798:10)
    r
    d
    +2
    • 5
    • 10
  • h

    huv1k

    11/25/2020, 10:26 AM
    I wonder if there is going to be better sync between new versions of prisma and support for
    nexus-plugin-prisma
    🙂
    🇨🇿 4
    👏 5
    r
    n
    +3
    • 6
    • 6
  • m

    Mikastark

    11/25/2020, 3:54 PM
    Since
    @nexus/schema@0.19
    is out and a new "list" "nullable "nonNull" API, which way is prefered ? 1. t.nonNull.list.nonNull.field(...) 2. t.field({ type: nonNull(list(nonNull(...))) ... }) I ask this question to prevent new eventual futur breaking changes
    t
    z
    w
    • 4
    • 5
1...131415...25Latest