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

    Timo

    11/26/2020, 1:33 PM
    I'm not really sure how to feel about the current way of enforcing change. While I really appreciate that you're focusing your energy on schema instead of the framework, getting hundreds of
    declarativeWrappingPlugin
    warnings is quite a lot. Now, I could simply use the plugin, but what if that code gets deprecated in the near future? Again, really appreciate the work you're doing! I'm simply missing a bit more communication on what we can expect from changes related to schema, because I'm not really too keen on rewriting my code over and over again.
    w
    t
    • 3
    • 5
  • p

    Peter

    11/26/2020, 7:00 PM
    Hi I have problem with passing arguments to query. I have that query
    Copy code
    export type input = keyof QueryGetBtsArgs;
    
    const getBts = async (_, arg) => {
      const variables = {
        ...arg,
      };
    
      const data = await client(
        endpoint,
        gql`
          query getBts($input: input) {
            getBts(input: $input) {
              province {
                name
              }
              provider {
                name
              }
              location {
                name
              }
            }
          }
        `,
        variables,
      );
    
      return data;
    };
    and my type QueryGetBtsArgs looks like this:
    Copy code
    export type QueryGetBtsArgs = {
      minLat?: Maybe<Scalars['Float']>;
      maxLat?: Maybe<Scalars['Float']>;
      minLong?: Maybe<Scalars['Float']>;
      maxLong?: Maybe<Scalars['Float']>;
      providers?: Maybe<Array<Maybe<ProviderEnum>>>;
      technologies?: Maybe<Array<Maybe<TechnologyEnum>>>;
      frequencies?: Maybe<Array<Maybe<FrequencyEnum>>>;
      province?: Maybe<ProvinceEnum>;
      location?: Maybe<Scalars['String']>;
      skip?: Maybe<Scalars['Int']>;
    };
    I have error
    Copy code
    Error: Unknown type "input". Did you mean "Int"?: {"response":{"errors":[{"message":"Unknown type \"input\". Did you mean \"Int\"?","locations":[{"line":2,"column":28}],"
    how I should extend this args from QueryGetBtsArgs and pass it to query? Thanks for help 😉
    r
    • 2
    • 12
  • e

    Elvijs

    11/27/2020, 10:03 PM
    Hello! I've just recently started using prisma+nexus and it is really handy and well maintained. I am having just a small hickup whilst deploying it all to aws with serverless. Error message will be enclosed in the thread! I'd be awesome if someone could help me address my problem! 😉 Thanks!
    r
    • 2
    • 4
  • j

    Justin Voitel

    11/28/2020, 5:32 PM
    Heya, has anyone successfully bundled a nexus + prisma app using esbuild ? unfortunately iam running into several errors
  • k

    Kevin Rejko

    12/01/2020, 8:01 PM
    Hello, does anyone know if there is updated documentation for Floggy? I am trying to follow this guide but the updated version of the library is generating a lot of errors. Edit: Or alternatively, does anyone have a different/better logging system that I could setup to help track down deployment issues?
    ✅ 1
    j
    • 2
    • 3
  • j

    Jonathan

    12/02/2020, 12:46 PM
    When is it required to specify a resolver for
    t.field
    . I sometimes have a parent fetching basically all properties for all the nested resolvers, but I dont wish to specify an explicit resolver bellow. If I were to do something like
    Copy code
    t.field('nestedField', { type: NestedFieldType, resolve: (parent => parent.nestedFieldType)})
    , typescript complains that parent has no property nestedFIeld
    r
    v
    • 3
    • 4
  • p

    Peter

    12/02/2020, 2:41 PM
    Hello 🤗 I have some problem with TS 😐 I try to add
    Copy code
    nonNullDefaults: {
        output: true,
      }
    to my existing objectType and have error on resolvers in this type
    Copy code
    Type '(root: Bts, args: any, ctx: { prisma: PrismaClient<PrismaClientOptions, never>; }) => Prisma__StationIdClient<StationId | null>' is not assignable to type 'FieldResolver<"Bts", "stationId">'.
      Type 'Prisma__StationIdClient<StationId | null>' is not assignable to type 'StationId | PromiseLike<StationId> | { id: MaybePromise<number>; name: MaybePromise<string>; } | PromiseLike<StationId | { ...; }>'.
        Type 'Prisma__StationIdClient<StationId | null>' is not assignable to type 'PromiseLike<StationId | { id: MaybePromise<number>; name: MaybePromise<string>; }>'.
          Types of property 'then' are incompatible.
            Type '<TResult1 = StationId | null, TResult2 = never>(onfulfilled?: ((value: StationId | null) => TResult1 | Promise<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | Promise<...>) | ... 1 more ... | undefined) => Promise<...>' is not assignable to type '<TResult1 = StationId | { id: MaybePromise<number>; name: MaybePromise<string>; }, TResult2 = never>(onfulfilled?: ((value: StationId | { id: MaybePromise<number>; name: MaybePromise<...>; }) => TResult1 | PromiseLike<...>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<...>) | ... 1 more ...'.
              Types of parameters 'onfulfilled' and 'onfulfilled' are incompatible.
                Types of parameters 'value' and 'value' are incompatible.
                  Type 'StationId | null' is not assignable to type 'StationId | { id: MaybePromise<number>; name: MaybePromise<string>; }'.
                    Type 'null' is not assignable to type 'StationId | { id: MaybePromise<number>; name: MaybePromise<string>; }'.
    
    67         resolve(root, args, ctx) {
               ~~~~~~~
    Object look like this
    Copy code
    export const Bts = objectType({
      name: 'Bts',
      description: 'BTS details',
      nonNullDefaults: {
        output: true,
      },
      definition(t) {
        t.id('id')
        t.string('lac'),
          t.string('btsid'),
          t.string('cid1'),
          t.string('ECID'),
          t.float('latitude'),
          t.float('longitude'),
          t.field('provider', {
            type: 'Provider',
            resolve(root, args, ctx) {
              return ctx.prisma.provider.findOne({
                where: { id: root.providerId },
              })
            },
          }),
          t.field('province', {
            type: 'Province',
            resolve(root, args, ctx) {
              return ctx.prisma.province.findOne({
                where: { id: root.provinceId },
              })
            },
          }),
          t.field('place', {
            type: 'Place',
            resolve(root, args, ctx) {
              return ctx.prisma.place.findOne({
                where: { id: root.placeId },
              })
            },
          }),
          t.field('location', {
            type: 'Location',
            resolve(root, args, ctx) {
              return ctx.prisma.location.findOne({
                where: { id: root.locationId },
              })
            },
          }),
          t.field('technology', {
            type: 'Technology',
            resolve(root, args, ctx) {
              return ctx.prisma.technology.findOne({
                where: { id: root.technologyId },
              })
            },
          }),
          t.field('frequency', {
            type: 'Frequency',
            resolve(root, args, ctx) {
              return ctx.prisma.frequency.findOne({
                where: { id: root.frequencyId },
              })
            },
          }),
          t.field('stationId', {
            type: 'StationId',
            resolve(root, args, ctx) {
              return ctx.prisma.stationId.findOne({
                where: { id: root.stationIdId },
              })
            },
          })
      },
    })
    and other type that is included here also have nonNullDefaults flag
  • s

    Swapnull

    12/02/2020, 4:35 PM
    Hey 🙂 We have basic auth set up using graphql-shield that checks auth via bearer token, but we want to further restrict what data they can access down to specific rows. eg. User A owns records 1, 2, 3 User B owns record 4, 5, 6 We ended up with something like
    Copy code
    const isAuthed = rule()(async (parent, args, ctx) => {
      const recordId = ctx.where?.id?.equals;
    
      /* do rest of auth using recordId */ 
    }
    This obviously sucks because if the FE chooses to use
    in
    or
    contains
    or any other input, it won't work. One thing we have thought is to allow something like
    Copy code
    query getRecords { 
      records(recordId: "someId") {
        uuid
      }
    }
    But when creating the record query we have
    Copy code
    t.crud.records({ filtering: true, ordering: true, pagination: true });
    and we can't find a way to say for type
    query
    on
    records
    accept a
    recordId
    argument. The other option is to run the query and then check when it comes back. Anybody have any thoughts on how they are authorising these types of owned records?
    r
    • 2
    • 2
  • s

    Stefan N

    12/03/2020, 7:51 AM
    Hey gentle Prisma folks 👋. I am currently migrating from nexus framework to @nexus/schema, using nexus-plugin-prisma running on next.js. I'm almost through with the migration but I'm stuck on one point: nexus-plugin-prisma is generating types into
    node_modules/@types/typegen-nexus-plugin-prisma/
    automatically when running the server in dev mode. But I need it to generate these types as a build step in CI/CD (otherwise next build fails as well). I do manage to generate the
    schema.graphql
    and
    nexus.ts
    running reflection like this
    npx ts-node -T ./graphql/schema/index.ts
    and using the flag
    shouldExitAfterGenerateArtifacts
    . But during this step, the nexus-plugin-prisma files do not seem to be generated. Here my code generating the schema: https://github.com/teachen-ch/voty/blob/d525c36a0a7cff85816804e86f3b854cac480d69/graphql/makeschema.ts#L12
    r
    • 2
    • 3
  • s

    Stefan N

    12/03/2020, 7:54 AM
    Oh, forgot to introduce myself 🙃. Stefan from Switzerland here, working on an open source project to bring democracy to schools 👉 voty.ch. We greatly profited from the speed of dev using the Prisma stack so far ❤️
    prisma cool 1
    👋 2
    🚀 3
    n
    • 2
    • 1
  • s

    Shreyas Sreenivas

    12/03/2020, 9:22 AM
    Hey! I’m completely new to the world of testing and I just looked into
    jest
    . Is there a reason why in the Nexus Documentation they’re using Snapshot testing instead of just using
    expect(result).toEqual(exampleResult)
    ? Is it just for convenience or is there something that I’m missing?
    d
    • 2
    • 3
  • s

    Stefan N

    12/03/2020, 12:57 PM
    Here's one thing I haven't found much documentation about and maybe someone can help shed some light on it: with nexus-plugin-prisma I have a total of four engines generating typescript-definitions: prisma for the db client, nexus for the graphql schema, nexus-plugin-prisma for some helpers and graphql-codegen for my frontend code (same next.js codebase). Essentially the defined types are highly similar with some nuances. I have a hard time selecting the types from the right packages and oftentimes I fight with small discrepancies in type definitions from e.g. a FieldResolver around nullability. Any hints which could make my life a bit easier?
    r
    • 2
    • 3
  • s

    Sytten

    12/03/2020, 7:37 PM
    Can you guys build a better GraphQL server that just works once you are done with schema. I am more than tired of Apollo….. Thanks in advance 😄
    😃 1
    t
    • 2
    • 10
  • p

    Paul Hendrickson

    12/03/2020, 9:30 PM
    Hey, all! I’m changing my Apollo Server to run on Fastify rather than Express, everything seemed to be working fine until I got this error. I’ve attached the error and my package.json. No idea what’s going on. Edit: I ended up copy pasting the code into a different commit and everything worked. I have no idea what happened but it works so I’m fine with it.
    s
    j
    • 3
    • 6
  • s

    sven

    12/04/2020, 10:07 AM
    Can anyone point me to an example that shows how to use the unionType ? I think I understand it but it doesnt behave the way I want it to.
    r
    • 2
    • 4
  • p

    Paul Hendrickson

    12/04/2020, 4:25 PM
    Is there any way to get the count for the entities returned. Like is it possible to do:
    Copy code
    customers(
    where: { firstName: startsWith: “Paul”, mode: insensitive }},
    first: 20
    orderBy: [{ lastName : asc }, { id : asc } ]
    ){
    firstName
    lastName
    count
    id 
    }
    so you can see how many Pauls there are but only return the first 20
    r
    • 2
    • 9
  • s

    sylflo

    12/04/2020, 7:19 PM
    I have a quick question, I am trying to type the return value or
    originalResolve
    , I am not even quite sure if it is useful. but is doing this, the correct way ?
    const customer: NexusGenObjects["Customer"] | null = await originalResolve(root, args, ctx, info);
    but once again, it's maybe quite useless to do so
    r
    • 2
    • 1
  • a

    Awey

    12/06/2020, 12:51 AM
    should
    idArg()
    or
    stringArg()
    be used with the
    uuid()
    that comes from prisma?
    r
    • 2
    • 1
  • s

    Stefan Trivuncic

    12/06/2020, 10:28 PM
    Quick question: How do you guys handle enums as an argument type? For example, in my
    Users
    model, I have a model called
    LocationStatus
    with the enum values set as:
    Copy code
    import { enumType } from '@nexus/schema'
    
    export const LocationStatus =  enumType({
        name: 'LocationStatus',
        members: ['ON', 'OFF', 'APP'],
        description: 'List of location status'
    })
    But I need to pass it as an argument here:
    Copy code
    t.field('setLocationStatus', {
            type: 'User',
            args: {
                locationStatus: arg({ type: 'LocationStatus', list: true})
            },
            resolve: async (_parent, { locationStatus }, ctx ) => {
                const userId = await getUserId(ctx)
                if (!userId) {
                  throw new Error('Invalid userId')
                }
    
                return await ctx.prisma.user.update({
                    where: {
                        id: userId
                    },
                    data: { locationStatus }
                })
            }
        })
    And the error I get is due to the conflicting input types:
    Type 'string | null | undefined' is not assignable to type '"ON" | "OFF" | "APP" | EnumLocationStatusFieldUpdateOperationsInput | undefined'.
    r
    • 2
    • 5
  • a

    Awey

    12/07/2020, 8:05 PM
    Given an enum like this
    Copy code
    enum PostType {
      story
      ask
      show
    }
    Would you write it like so in NexusSchema?
    Copy code
    const PostType = enumType({
      name: 'PostType',
      members: ['story', 'ask', 'show'],
    })
    How then would I go about using this PostType enum as an argument?
    Copy code
    args: {
      title: nonNull(stringArg()),
      type: nonNull(PostType),
      url: stringArg(),
      content: stringArg(),
    },
    s
    r
    • 3
    • 5
  • a

    Awey

    12/08/2020, 11:43 PM
    are there any examples using nexus schema with next-auth? I'm trying to setup auth (have been for a while) and it's kicking my ass.
    r
    • 2
    • 8
  • s

    Slackbot

    12/09/2020, 8:32 PM
    This message was deleted.
    a
    j
    r
    • 4
    • 5
  • a

    Adam

    12/10/2020, 12:59 AM
    I want to make sure I'm writing my
    authroization
    resolvers correctly. So if I have two related tables, and need to implement a custom
    resolver
    for retrieving
    Projects
    based on permissions, then I have to put it on both entities? I thought if I typed a field as a related
    object
    then it would use that object's resolver? It seems like identical logic could get duplicated in quite a few places to cover all the related entities that might request a related objectType
    Copy code
    model Organization {
      id        Int       @id @default(autoincrement())
      projects  Project[]
    }
    
    model Project {
      id                 Int                  @id @default(autoincrement())
      organization       Organization         @relation(fields: [organizationId], references: [id])
      organizationId     Int
    }
    And then I define the types for each
    Copy code
    export const OrganizationType = objectType({
      name: 'Organization',
      definition(t) {
        const { model } = t;
        model.id();
        model.projects({
          async resolve(_root, { where }, ctx, info, originalResolve) {
           /** I Also need to put the logic here? If it knows I'm querying a Project, why doesn't it use the same logic? **/
          }
          });
      },
    });
    
    export const ProjectType = objectType({
      name: 'Project',
      definition(t) {
        const { model } = t;
        model.id();
        model.organizationId({});
        model.organization({});
      },
    });
    
    export const ProjectQueries = extendType({
      type: 'Query',
      definition(t) {
        const { crud } = t;
    
      crud.project({
          filtering: true,
          async resolve(_root, { where }, ctx, info, originalResolve) {
           /** Filter only the projects that the user can see **/
          }
      });
  • d

    Dickson

    12/10/2020, 5:12 AM
    Hi there 👋, I recently tried out deploying prisma with serverless according to the example from @Ryan: https://github.com/ryands17/serverless-prisma I deployed it to AWS lambda and connected it to a aurora rds MySQL database, it works fine when it works, expect when it give a
    write EPIPE
    error every now and then
    Copy code
    {
      "errors": [
        {
          "message": "write EPIPE",
          "locations": [
            {
              "line": 2,
              "column": 3
            }
          ],
          "path": [
            "users"
          ],
          "extensions": {
            "code": "INTERNAL_SERVER_ERROR",
            "exception": {
              "code": "EPIPE",
              "clientVersion": "2.12.1"
            }
          }
        }
      ],
      "data": null,
      "extensions": {
        "tracing": {
          "version": 1,
          "startTime": "2020-12-10T04:52:35.819Z",
          "endTime": "2020-12-10T04:52:35.827Z",
          "duration": 8377223,
          "execution": {
            "resolvers": [
              {
                "path": [
                  "users"
                ],
                "parentType": "Query",
                "fieldName": "users",
                "returnType": "[User!]!",
                "startOffset": 344494,
                "duration": 6622886
              }
            ]
          }
        }
      }
    }
    What could have gone wrong?
    r
    • 2
    • 12
  • d

    Daniell

    12/10/2020, 8:34 AM
    Does anyone know why I'm not getting any graphql types generated?
    d
    • 2
    • 49
  • d

    Daniell

    12/12/2020, 8:37 AM
    I created an api with nexus schema and prisma, what is your fav way of consuming a graphql api in next.js? I know there is graphql codegen but what do you use it with?
    v
    • 2
    • 4
  • s

    Sytten

    12/13/2020, 4:07 PM
    @jasonkuhrt Is there a way to inject a plugin input in the prisma plugin generated models? I got a request to use nexus-shield with the plugin but I don’t see anything that tells me that would be possible. https://github.com/Sytten/nexus-shield/issues/181
    j
    w
    • 3
    • 4
  • a

    Alex Vilchis

    12/14/2020, 6:26 PM
    Congrats con the 1.0 release! 🎉
    prisma rainbow 7
    🙏🏻 1
  • a

    Albert Gao

    12/15/2020, 3:13 AM
    I was using nexus/schema 0.19, seems the migration to nexus is as easy as replace all… xD
    🙌 5
    fast parrot 4
  • r

    Ricardo Almeida

    12/15/2020, 8:46 AM
    Hi there! I got errors migrating to 1.0.0
    ✅ 1
    r
    • 2
    • 6
1...141516...25Latest