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

    Cameron

    04/30/2020, 4:06 AM
    Coming from
    yoga
    or looking for an example
    nexus@next
    framework project with authentication and
    graphql-shield
    permissions? Check this out: https://github.com/Camji55/nexus-plugin-jwt-auth/tree/master/examples/shield It utilizes: Token authentication:
    nexus-plugin-jwt-auth
    https://github.com/Camji55/nexus-plugin-jwt-auth Permissions:
    nexus-plugin-shield
    https://github.com/lvauvillier/nexus-plugin-shield
    šŸ‘ 2
  • a

    Alex Vilchis

    04/30/2020, 2:30 PM
    I have a problem with
    subscriptionField
    Copy code
    import { subscriptionField } from '@nexus/schema';
    import { Context } from '../context';
    import { withFilter } from 'apollo-server';
    
    export const Subscription = subscriptionField('onNewEmployeeMessage', {
      type: 'EmployeeChatMessage',
      subscribe: (root, args, ctx: Context) => {
        console.log(ctx);
        return withFilter(
          () => ctx.pubsub.asyncIterator('onNewEmployeeMessage'),
          (payload, variables) => {
            return true;
          }
        );
      },
      resolve: payload => payload
    });
    
    export default Subscription;
    I am trying to use Apollo’s withFilter function to filter my async iterator results. However, the return type of withType is not what nexus expects in the subscribe field. Any ideas?
    • 1
    • 1
  • i

    Ian Wensink

    04/30/2020, 2:30 PM
    Question about Nexus. I have a custom type definition, which is not picked up by Nexus during build. It is by TSC and the editor, though, so don’t really understand why this is happening. According to the docs Nexus respects the
    tsconfig.json
  • r

    rdunk

    04/30/2020, 10:01 PM
    I’ve just spent a couple of weeks (at least) building something with Nest/GraphQL/TypeORM. Today I looked into Prisma a bit more as I was seriously not enjoying Nest and writing mutation resolvers and convoluted TypeORM transactions over and over. I’ve just replicated most of the Nest app with Nexus in a couple of hours.
    šŸ’Æ 1
    šŸ‘ 1
  • r

    rdunk

    04/30/2020, 10:03 PM
    Really love finding tools like this where you feel like someone has encountered and solved all of your problems for you already.
  • p

    Paul

    05/03/2020, 3:56 PM
    Hi, does any one have an issue with being unable to run a local server with
    npm run dev
    ? It lets me now that server is listening on localhost:4000, however when I open playground at that address I'm getting
    Server cannot be reached
    on the right side of the url field and below error in the graphql response area:
    Copy code
    {
      "error": "JSON.parse: unexpected character at line 1 column 1 of the JSON data"
    }
    dependencies:
    Copy code
    "dependencies": {
        "@types/bcrypt": "^3.0.0",
        "@types/jsonwebtoken": "^8.3.9",
        "bcrypt": "^4.0.1",
        "env-cmd": "^10.1.0",
        "jsonwebtoken": "^8.5.1",
        "nexus": "^0.21.0-next.21",
        "nexus-plugin-prisma": "^0.7.0",
        "nexus-plugin-shield": "^0.1.2"
      }
    • 1
    • 1
  • o

    Oliver Evans

    05/04/2020, 2:25 PM
    Can anyone provide some guidance on schema stitching with nexus? I would love to be able to combine my services in a code-first, type-safe way, but the only info I can find is this outdated and inconclusive github issue: https://github.com/graphql-nexus/schema/issues/70
    w
    • 2
    • 5
  • b

    blocka

    05/05/2020, 2:09 AM
    I'm trying to implement a union type and getting the following error
    Copy code
    Expected ErrorResponse to be a objectType, saw GraphQLScalarType
    This is what I did
    Copy code
    const ErrorResponse = objectType({
      name: 'ErrorResponse',
      definition(t) {
        t.string('error')
      }
    })
    
    const CreatedObjectResponse = objectType({
      name: 'CreatedObjectResponse',
      definition(t) {
        t.id('id')
      }
    })
    
    const CreateLearningResponse = unionType({
      name: 'CreateLearningReponse',
      definition(t) {
        t.members(ErrorResponse, CreatedObjectResponse)
        t.resolveType((e) => (e.error ? ErrorResponse : CreatedObjectResponse))
      }
    })
    When I plug this code into the playground, it works as expected
  • l

    Lars-JĆørgen Kristiansen

    05/08/2020, 10:32 AM
    Is it possible to add `@cacheControl`directive with nexus?
  • l

    lewebsimple

    05/09/2020, 2:28 AM
    Anybody got
    @nexus/schema
    +
    nexus-prisma
    to work with
    graphql-modules
    ? I’m having trouble configuring
    nexusPrismaPlugin
    so it can find the prisma client
  • l

    lewebsimple

    05/09/2020, 2:30 AM
    I can get
    @nexus/schema
    to work on its own (i.e. without prisma) though
  • m

    mjyoung

    05/09/2020, 3:45 AM
    The whole nexus and prisma ecosystem is a bit of a mess. they’re taking ā€œmove fast and break thingsā€ to a whole new level
  • m

    mjyoung

    05/09/2020, 3:48 AM
    For example:
    nexus-prisma
    https://www.nexusjs.org/#/components/schema/plugins/prisma
    nexus-plugin-prisma
    https://www.nexusjs.org/#/plugins/prisma I’m not sure what the difference is between the two. I just grabbed nexus-plugin-prisma yesterday and it’s working. As in, nexus recognizes it and is able to pull in the client. Have to make sure I don’t have
    @prisma/client
    installed as a dependency since
    nexus-plugin-prisma
    bundles that already
    l
    • 2
    • 2
  • j

    Josef Henryson

    05/11/2020, 2:28 PM
    Hi, I am using prisma 1 still and tries to make a nexus resolver for a nested field. E.g: User > Post > Comment that should return custom comment based on Post field I can add t.field(ā€˜post’) on user, but I don’t seem to be able to overwrite the comment response on the post object. Should it be possible to achieve this in some way??
    s
    • 2
    • 1
  • c

    Cihad Turhan

    05/12/2020, 3:14 PM
    Hello, I have a question: I want to define a custom object arg and use that arg in multiple mutations such as:
    Copy code
    const myCustomArg = {
       id: stringArg(),
       name: stringArg()
    }
    
    ...
    t.field('updateFoo', {
       type: 'Bar',
       args: {
         userId: stringArg(),
         custom: myCustomArg
         //      ^^ I want to use it here
       }
       ...
    })
    How to use it? Thanks
  • c

    Cihad Turhan

    05/12/2020, 4:09 PM
    ok found out!
    Copy code
    const DeviceInputType = inputObjectType({
       name: 'DeviceInputType',
        definition(t) {
            t.string('id', {nullable: false});
            t.field('type', { type: "DeviceType", required: true});
        }
    });
    
    //and use it as argument:
    DeviceInputType.asArg()
  • g

    Guillermo Lopez

    05/16/2020, 5:43 PM
    Quick question: Is Nexus already compatible with Schema directives?
    d
    • 2
    • 1
  • r

    Roy

    05/16/2020, 9:10 PM
    Hi guys. I have a problem with a mutation with a connection and need some help. This is my schema.prisma:
    Copy code
    model Menu {
      id        Int          @default(autoincrement()) @id
      name      String
      company   Company      @relation(fields: [companyId], references: [id])
      companyId Int
      isActive  Boolean
      items     ItemOnMenu[]
    }
    
    model ItemOnMenu {
      id          Int           @default(autoincrement()) @id
      item        Item          @relation(fields: [itemId], references: [id])
      itemId      Int
      ItemOnOrder ItemOnOrder[]
      course      String
      Menu        Menu          @relation(fields: [menuId], references: [id])
      menuId      Int
    }
    In graphql.ts i have:
    Copy code
    schema.objectType({
      name: 'Menu',
      definition(t) {
        t.model.id();
        t.model.name();
        t.model.items();
        t.model.company();
        t.model.companyId();
        t.model.isActive();
      },
    });
    
    schema.objectType({
      name: 'ItemOnMenu',
      definition(t) {
        t.model.id();
        t.model.item();
        t.model.itemId();
        t.model.ItemOnOrder();
        <http://t.model.Menu|t.model.Menu>();
        t.model.menuId();
        t.model.course();
        t.model.price();
      },
    });
    When i run the following mutation, it will give me an error. The id is in my database, i verified that. This is the mutation:
    Copy code
    mutation createNewItemOnMenu(
      $item: "test"
      $course: "testCourse"
      $price: 2.75
    ) {
      createOneItemOnMenu(
        data: {
          item: { create: { name: $item } }
          course: $course
          price: $price
          Menu: { connect:{id: 60} }
        }
      ) {
        id
        item {
          name
        }
      }
    }
    This is the error which gives me a really big headache.
    Copy code
    "message": "\n\u001b[31mInvalid \u001b[1m`prisma.itemOnMenu.create()`\u001b[22m invocation:\u001b[39m\n\n Null constraint violation on the fields: (`id`)",
    Anyone there who can help me? I am running:
    Copy code
    "@prisma/cli": "^2.0.0-beta.4",
    "@prisma/client": "^2.0.0-beta.4",
    "nexus-plugin-prisma": "^0.8.0-next.9",
  • r

    rdunk

    05/18/2020, 10:55 AM
    Hello, not sure if this is the right place to ask, but I’m trying to execute a singe mutation that creates two types of entity and connects one to the other, is that possible?
    Copy code
    mutation createOneFoo {
      createOneFoo(
        data: {
          slug: "my-foo"
          bars: { create: [{ slug: "my-bar" }] }
          bazs: [
            { slug: "my-baz", bar: { connect: { slug: "my-bar" } } }
            { slug: "my-other-baz", bar: { connect: { slug: "my-bar" } } }
          ]
        }
      ) {
        slug
        bazs {
          slug
          bar {
            slug
          }
        }
      }
    }
  • r

    rdunk

    05/18/2020, 10:58 AM
    So here I’m trying to create a
    bar
    entity, but also create multiple
    baz
    entities and connect them to the created
    bar
    . I seem to get an error like this:
    AssertionError(\"[Query Graph] Expected a valid parent ID to be present for a nested connect on a one-to-many relation.
    but obviously in my case I don’t yet have an ID for the entity I want to connect.
    r
    • 2
    • 3
  • r

    rdunk

    05/18/2020, 11:30 AM
    I’m assuming I’ll need to split this into two separate mutations: one to create the
    bar
    entity, one to create the
    foo
    and
    baz
    entities and connect them to the
    bar
    . I see why now transactions are a wanted feature šŸ™‚
  • r

    rdunk

    05/21/2020, 9:52 AM
    Anyone managed to find a workaround for using
    Json
    types in your prisma schema? https://github.com/graphql-nexus/nexus/issues/839
    šŸ‘€ 2
  • r

    rdunk

    05/21/2020, 9:53 AM
    Seems fine from a prisma perspective, but the
    @nexus/schema
    package doesn’t seem to like Json
  • a

    Alex Vilchis

    05/22/2020, 2:46 PM
    Hello, is there a way to get a
    hasNextPage
    from generated prisma-nexus fields? Or is this something I can add through a plugin? Thank you
  • j

    Justin Voitel

    05/25/2020, 8:37 PM
    heya is there currently a way to do some action when the schema is new generated (using generateGraphQLSDLFile: true ) ? In my case I want to rerun a generator for queries each time the schema is regenerated
  • h

    huv1k

    05/26/2020, 7:04 PM
    What is state
    nexus-prisma
    regarding prisma?
    s
    • 2
    • 2
  • m

    mattadore

    05/27/2020, 3:44 AM
    Hi, what is the reasoning behind the nexus-prisma-plugin typegen system not acknowledging that resolver root/parent objects could contain the associated "includes" fields? As it is right now it seems to only generate type properties for scalar fields on the object itself, and not for linked objects (or scalars that act as foreign keys). It could at least include properties typed as potentially null or undefined to indicate that such properties could exist on the object, even if they aren't guaranteed to. As it stands I'm not sure what a good workaround would be since the nexus types are generated, so manually extending/editing them on a case by case basis isn't really a scalable solution.
    • 1
    • 2
  • s

    Samrith Shankar

    05/30/2020, 1:30 AM
    Does Nexus not support absolute imports? I just ported a huge project to nexus, and it started throwing errors that it can’t find modules.
  • s

    Samrith Shankar

    05/30/2020, 2:59 AM
    Can someone here help me out with an error? I keep getting this error:
    Copy code
    Error: Query was already defined and imported as a type, check the docs for extending types
    I am using
    queryType
    to create my queries and am modularising it in files. How do I do it? And what docs do I read?
    t
    • 2
    • 8
  • m

    mjyoung

    06/03/2020, 11:28 PM
    šŸ‘‹Ā  I don’t see a way to create issues inĀ 
    nexus-plugin-prisma
    , but im using nexus with prisma and im trying to create a record that has a Json field.Ā (edited)Ā  I’m running into the same error this user experienced: https://github.com/prisma/prisma-client-js/issues/680 Is nexus-plugin-prisma updated with the latestĀ 
    @prisma/client
    ?
    • 1
    • 1
1...456...25Latest