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

    stephen.pearl

    01/25/2021, 9:08 PM
    Is there an example of nested inputs? I don't see anything in the docs and this seems like a common use case. For example, I'd like to create an Article { author { name, yearsOfExperience}}
    d
    • 2
    • 1
  • s

    sven

    01/26/2021, 12:47 PM
    Can I have a list of objects as an argument?
    d
    • 2
    • 4
  • j

    John Smeeth

    01/27/2021, 7:22 AM
    hi all, i'm using
    nexus-plugin-prisma: 0.28.0
    2.14
    in my query i have definition with args
    Copy code
    args: { 
            lowPrice: floatArg(),
            highPrice: floatArg(),
          },
    And in the resolver i got error in typechecking
    Copy code
    Type 'number | null | undefined' is not assignable to type 'number | undefined'.
      Type 'null' is not assignable to type 'number | undefined'.ts(2322)
    What wrong with me? Please give me an advice, many thank
  • j

    John Smeeth

    01/27/2021, 7:24 AM
    my query condition
    Copy code
    AND: [
                  { price: { gte: lowPrice } },
                  { price: { lte: highPrice } },
                ],
    r
    • 2
    • 5
  • s

    stephen.pearl

    01/27/2021, 5:31 PM
    Why doesn't typescript recognize JSON types when defining object fields in my schema? Ex. t.Json('additionalPay');` I configured the nexusPrisma configuration with the following:
    Copy code
    scalars: {
      DateTime: DateTimeResolver,
      Json: new GraphQLScalarType({
        ...JSONObjectResolver,
        name: 'Json',
        description:
          'The `JSON` scalar type represents JSON objects as specified by [ECMA-404](<http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf).>'
      })
    }
    I am following the README here (https://github.com/graphql-nexus/nexus/blob/b327841a6380f80043705b20348fce21b0bf50[…]ontent/040-adoption-guides/030-neuxs-framework-prisma-users.mdx) and it seems like a step is missing.
    d
    • 2
    • 1
  • d

    Daniel Mahon

    01/27/2021, 7:49 PM
    Hello all, how do you reference a derived Nexus type in another type’s resolver?
  • d

    Daniel Mahon

    01/27/2021, 7:50 PM
    given this derived type
    Copy code
    export const ToolStatePayload = objectType({
      name: 'ToolStatePayload',
      definition: (t) => {
        t.model('ToolState').id();
        t.model('ToolState').createdAt();
        t.model('ToolState').statusCode();
        t.list.toolStateLance('lances');
      },
    });
  • d

    Daniel Mahon

    01/27/2021, 7:51 PM
    how do you get the proper type here?
    Copy code
    export const toolStates = extendType({
      type: 'Query',
      definition: (t) => {
        t.field('getPostJobData', {
          type: list('ToolStatePayload'),
          args: {
            ids: nonNull(list(nonNull(idArg()))),
          },
          resolve: async (_parent, { ids }, ctx: Context) => {
    
            // HERE /////////////////////////////////////
            let states: NexusObjectTypeDef<'ToolStatePayload'>[] = [];
    ...
  • d

    Daniel Mahon

    01/27/2021, 7:52 PM
    or am I missing a better way to return a “partial” type from a resolver?
  • d

    Daniel Mahon

    01/27/2021, 9:46 PM
    I think I found it, needed to use “NexusGenObjects”
    let states: NexusGenObjects['ToolStatePayload'][] = [];
    💯 1
  • j

    Jonathan

    01/27/2021, 10:06 PM
    This is more of a general Graphql-in-nodejs question, but who uses the dependency-injection pattern in their graphql resolvers? We are considering refactoring some part of our Services to be made available from a container (as we are experiencing some import-hell atm), but we like to see what the recommended approach is (`typedi`/`inversify`)?
  • s

    Spiros - Product at Prisma

    01/28/2021, 11:13 AM
    Hello everyone, I'd like to share some updates on the Nexus Prisma Plugin that we made public in our Github repo yesterday: • We are planning to release a new, more stable, version of the plugin which will have a different set of fuctionalities than the current one. • We will temporarily drop support for it in order to focus on rewriting the codebase to get to the new scope. • We are committed to maintaining the plugin in the long term. You can read more information in the Github issue: https://github.com/graphql-nexus/nexus-plugin-prisma/issues/1039 Thank you for your patience and help so far!
    💯 4
    prisma rainbow 4
    m
    • 2
    • 2
  • b

    Bruno Borges

    01/31/2021, 2:59 PM
    Heey prisma people! I need to filter the result of a query generated by t.crud. The situation is: The user requesting the data, does not have permission to see all results that they might be requesting. Is there any way of doing that, or only creating a custom query to solve this problem?
    s
    • 2
    • 2
  • m

    Michael

    02/01/2021, 12:51 PM
    Hey everyone, I am using apollo and nexus prisma. When using my mutation, I want to pass an array of data to nexus prisma but my schema doesn’t fit the input. I created a custom inputObjectType and added it to my mutation. `export const UPDATE_MILESTONES = gql``
    mutation updateMilestones($input: [MilestoneInput!]) {
    updateMilestones(input: $input) {
    id
    orderIndex
    }
    }
    ``;`
    export const milestoneInput = inputObjectType({
    name: "MilestoneInput",
    definition(t) {
    t.string("id");
    <http://t.int|t.int>("orderIndex");
    },
    });
    So when I pass
    mutation {
    updateMilestones(input: [{id: "123", orderIndex:1}, { id: "42", orderIndex: 2}]) {
    id
    }
    }
    I get this error: “Expected value of type \“MilestoneInput\“, found [{id: \“123\“, orderIndex: 1}, {id: \“42\“, orderIndex: 2}].“, Any advice? I coulnd’t find a solution yet. 🤔
    r
    • 2
    • 5
  • b

    Brandon Wang

    02/01/2021, 10:35 PM
    Is there a good solution for adding the CRUD query/mutation to a custom type? The use case is that we’ve written something to transform the output of a JSON blob from the database to the GraphQL client and want to be able to use that transformer when querying the lists.
  • d

    Daniell

    02/01/2021, 10:54 PM
    I am still very early in a serious project with nexus-plugin-prisma only used for a single object type for testing and I read this today https://github.com/graphql-nexus/nexus-plugin-prisma/issues/1039 ~ why does it mention
    if you have any questions about removing the the nexus-plugin-prisma from your application
    ? I am not sure what to do at this point
    b
    d
    • 3
    • 11
  • s

    Stephen Flannery

    02/02/2021, 3:53 AM
    I have an implicit many to many relationship i created with prisma. I cant seem to find much documentation on creating mutations with nexus for these. I have servers and users. Users have
    Copy code
    servers       Server[]
    and Servers have
    Copy code
    users      User[]
    and I would like users to be able to join servers. Any help is appreciated. Thanks.
    r
    • 2
    • 2
  • m

    Manthan Mallikarjun

    02/04/2021, 8:43 AM
    Anyone else getting this error?
    Property 'date' does not exist on type 'Pick<OutputDefinitionBlock<"DataFeedItem">, "string" | "boolean" | "id" | "typeName" | "list" | "int" | "float" | "field">'.
    ? I followed this guide https://nexusjs.org/docs/adoption-guides/nexus-framework-users#bundled-scalars and
    t.nullable.date
    even pops up with vscode autocomplete so im pretty sure I did it right but typescript complains
    j
    j
    • 3
    • 8
  • t

    Timo

    02/04/2021, 9:21 AM
    Is it normal that Nexus is creating the following SQL query for Prisma for
    t.model.meta
    within an
    post
    object
    Copy code
    Post:findUnique:{"where":{"id":"sktwi7ggkkmcytvo1fdac53cef1a6129"},"select":{"meta":{}}}'
    instead of
    Copy code
    Post:findUnique:{"where":{"id":"sktwi7ggkkmcytvo1fdac53cef1a6129"},"include":{"meta":true}}
  • t

    Timo

    02/04/2021, 9:22 AM
    Or at least something like this
    Copy code
    Meta:findUnique:{"where":{"postId":"sktwi7ggkkmcytvo1fdac53cef1a6129"}}
  • t

    Timo

    02/04/2021, 9:23 AM
    Because otherwise, the caching solution I'm using (https://prisma.slack.com/archives/CKQTGR6T0/p1612265466393100?thread_ts=1612258798.391400&amp;cid=CKQTGR6T0) sets the single
    meta
    object as the
    post
    with id
    sktwi7ggkkmcytvo1fdac53cef1a6129
  • s

    slinden

    02/04/2021, 12:34 PM
    I am encountering a problem that causes very slow queries using
    prisma2
    ,
    nexus
    and
    nexus-plugin-prisma
    . The problem happens in a simple query that gets data from multiple tables. GraphQL objects:
    Copy code
    export const Conference = objectType({
      name: "Conference",
      definition(t) {
        t.model.id();
        t.model.divisions();
      },
    });
    
    export const Division = objectType({
      name: "Division",
      definition(t) {
        t.model.id();
        t.model.conferences();
      },
    });
    
    export const DivisionConference = objectType({
      name: "DivisionConference",
      definition(t) {
        t.model.id();
        t.model.season();
        t.model.conference();
        t.model.conferenceId();
        t.model.division();
        t.model.divisionId();
      },
    });
    I have setup
    divisions
    query using
    t.crud
    like this:
    Copy code
    export const DivisionQuery = extendType({
      type: "Query",
      definition(t) {
        t.crud.divisions();
      },
    });
    And my GraphQL query is like this:
    Copy code
    query {
      divisions {
        id
        conferences {
          season
          conference {
            id
          }
        }
      }
    }
    I have currently 8 divisions in the database out of which 4 are connected to 1 conference each via that
    DivisionConference
    table. These are the logged queries: https://pastebin.com/HkX8c4jc I mean, that is a simple query. I am surely doing something wrong, but don't know what :)
    r
    • 2
    • 4
  • n

    nikolasburk

    02/05/2021, 10:58 AM
    Hey Prisma friends <!here> 👋 In case you haven't seen it, we just published the first part of a migration guide that explains how to remove
    nexus-plugin-prisma
    from your GraphQL Nexus app. It covers how to use Nexus' native
    t.field()
    API instead of the plugin's
    t.model()
    to expose the fields of your Prisma models to GraphQL. We'll add the second part covering the migration process for
    t.crud()
    soon. I've also elaborated a bit on @Spiros - Product at Prisma's initial message in the GitHub issue about the future of the
    nexus-plugin-prisma
    to explain a bit more how we've gotten into this situation. We know that the recent and sudden changes have caused a lot of frustration among a lot of you and want to apologize for the poor communication about the state of the plugin over the past year! Please feel free to reach out to me personally if you have any questions about how to move forward with your project or if there's anything else that I can help you with! 🙏
    ❤️ 13
    😂 2
    🤦 2
    👍 3
    windows 2
    💯 9
    parrotwave1 2
    graphcool 3
    a
    m
    +3
    • 6
    • 9
  • m

    mikkelsl

    02/08/2021, 9:04 PM
    Anyone who can recommend some resources on structuring a medium-large sized nexus/apollo-server-express application with a feature-based/modular approach? After losing Nexus framework, it's becoming quite a pain point. I've been looking into graphql-modules and graphql-tools. Not really sure though.
  • s

    slinden

    02/09/2021, 10:22 AM
    I have almost completed the 
    nexus-plugin-prisma
     => 
    nexus
     migration, but I am encountering a problem with all relations to one particular table and can't figure out whats the problem. Here is some code:
    Copy code
    model Player {
      id                   String           @id @default(cuid())
      playerIdApi          Int              @unique
      firstName            String
      lastName             String
      ...
      ...
      teams                PlayerTeam[]
      skaterBoxscores      SkaterBoxscore[] @relation("PlayerSkaterBoxscores")
      goalieBoxscores      GoalieBoxscore[] @relation("PlayerGoalieBoxscores")
      highlightMetaGoal    HighlightMeta[]  @relation("PlayerHighlightMetaGoal")
      highlightMetaAssist1 HighlightMeta[]  @relation("PlayerHighlightMetaAssist1")
      highlightMetaAssist2 HighlightMeta[]  @relation("PlayerHighlightMetaAssist2")
      highlightMetaGoalie  HighlightMeta[]  @relation("PlayerHighlightMetaGoalie")
      favoritedBy          User[]           @relation("UserFavoritePlayers")
    }
    
    export const User = objectType({
      name: "User",
      definition(t) {
        t.nonNull.string("id");
        ...
        ...
        t.nonNull.list.field("favoritePlayers", {
          type: "Player",
          resolve: async (parent, _, ctx) => {
            return await ctx.prisma.user
              .findUnique({ where: { id: parent.id } })
              .favoritePlayers();
          },
        });
      },
    });
    I have defined several relation like this, but I get an error every time I am creating a relation to
    type: "Player"
    in all
    objectTypes
    . In the
    User
    type the error is this:
    Copy code
    Type '(parent: { createdAt: any; email: string; id: string; isVerified: boolean; role: "ADMIN" | "MODERATOR" | "USER"; updatedAt: any; username: string; usernameLower: string; }, _: {}, ctx: Context) => Promise<...>' is not assignable to type 'FieldResolver<"User", "favoritePlayers">'.
      Type 'Promise<Player[]>' is not assignable to type '({ active: string; alternateCaptain: boolean; birthCity: string; birthCountry: string; birthDate: any; birthStateProvince?: string | null | undefined; captain: boolean; firstName: string; ... 12 more ...; weight: number; } | null)[] | PromiseLike<...> | MaybePromise<...>[] | PromiseLike<...>'.
        Type 'Promise<Player[]>' is not assignable to type 'PromiseLike<MaybePromise<{ active: string; alternateCaptain: boolean; birthCity: string; birthCountry: string; birthDate: any; birthStateProvince?: string | null | undefined; captain: boolean; firstName: string; ... 12 more ...; weight: number; } | null>[]>'.
          Types of property 'then' are incompatible.
            Type '<TResult1 = Player[], TResult2 = never>(onfulfilled?: ((value: Player[]) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<...>) | null | undefined) => Promise<...>' is not assignable to type '<TResult1 = MaybePromise<{ active: string; alternateCaptain: boolean; birthCity: string; birthCountry: string; birthDate: any; birthStateProvince?: string | null | undefined; captain: boolean; firstName: string; ... 12 more ...; weight: number; } | null>[], TResult2 = never>(onfulfilled?: ((value: MaybePromise<...>[...'.
              Types of parameters 'onfulfilled' and 'onfulfilled' are incompatible.
                Types of parameters 'value' and 'value' are incompatible.
                  Type 'Player[]' is not assignable to type 'MaybePromise<{ active: string; alternateCaptain: boolean; birthCity: string; birthCountry: string; birthDate: any; birthStateProvince?: string | null | undefined; captain: boolean; firstName: string; ... 12 more ...; weight: number; } | null>[]'.
                    Type 'Player' is not assignable to type 'MaybePromise<{ active: string; alternateCaptain: boolean; birthCity: string; birthCountry: string; birthDate: any; birthStateProvince?: string | null | undefined; captain: boolean; firstName: string; ... 12 more ...; weight: number; } | null>'.
                      Type 'Player' is not assignable to type '{ active: string; alternateCaptain: boolean; birthCity: string; birthCountry: string; birthDate: any; birthStateProvince?: string | null | undefined; captain: boolean; firstName: string; height: number; ... 11 more ...; weight: number; }'.
    d
    • 2
    • 40
  • a

    Awey

    02/09/2021, 7:49 PM
    Do I have prisma/nexus setup properly with nextjs? https://github.com/abdiweyrah/hackernews I keep getting the following error
    Copy code
    "message": "Cannot read property 'post' of undefined",
    on this query
    Copy code
    {
      posts {
        id
        createdAt
        title
        author {
          name
        }
      }
    }
    The files are in
    /src
    /pages/api/graphql.ts
    and
    /pages/_app.tsx
    ✅ 1
    a
    • 2
    • 5
  • s

    slinden

    02/10/2021, 4:49 PM
    I don't understand why I need to define a resolveType for a
    interfaceType
    . I mean, if I create an interface that is used in multiple `objectType`s shouldnt I just define the type in the
    objectType
    ?
  • s

    slinden

    02/12/2021, 12:48 PM
    I have a field in an object say
    <http://t.nonNull.int|t.nonNull.int>("gamePks")
    . I would like to modify it before sending it to the client. I tried this:
    Copy code
    t.nonNull.list.nonNull.field("gamePks", {
          type: "String",
          resolve: (parent) => {
            return parent.gamePks.split(", ");
          },
        });
    This works, but I get a type error on
    parent.gamePks
    . The error is that it doesnt exist in the parent. The object definition is like this:
    Copy code
    export const BestSkater = objectType({
      name: "BestSkater",
      isTypeOf() {
        return true;
      },
      definition(t) {
        t.implements("BestPlayer");
        <http://t.nonNull.int|t.nonNull.int>("points");
        .
        .
        .
        t.nonNull.list.nonNull.field("gamePks", {
          type: "String",
          resolve: (parent) => {
            return parent.gamePks.split(", ");
          },
        });
      },
    });
    r
    • 2
    • 9
  • m

    Meiri Anto

    02/12/2021, 11:45 PM
    writing a custom resolver for a
    t.model
    is giving me errors because the
    root
    is type of the field which is
    string
    not the parent type
    IntakeApplication
    Copy code
    t.model.name({
          authorize: (_parent, _args, ctx) => isAdmin(ctx),
          resolve: async (parent, args, ctx, info, originalResolve) => {
            const res = await originalResolve(parent, args, ctx, info);
            return res;
          },
        });
    error I'm getting with parameter
    parent
    in line 4:
    Copy code
    Argument of type 'string' is not assignable to parameter of type 'IntakeApplication'.ts(2345)
    r
    • 2
    • 6
  • j

    Julien Goux

    02/15/2021, 1:45 PM
    Hello all
    🙌 1
    👋 2
1...171819...25Latest