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

    Julien Goux

    02/15/2021, 1:49 PM
    How hard would it be to make an helper that typecheck well for creating mutationField :
    Copy code
    // What I have currently
    export const createTask = mutationField("createTask", {
      args: {
        input: nonNull(
          inputObjectType({
            definition(t) {
              t.nonNull.string("name");
            },
            name: "CreateTaskInput",
          })
        ),
      },
      resolve(_root, args, ctx) {
      },
      type: task,
    });
    
    // What I'd like
    mutationField("createTask", {
      input(t) {
        t.nonNull.string("name");
      }
      resolve() {},
      type: task
    })
  • j

    Julien Goux

    02/15/2021, 1:49 PM
    I want to enforce the way we name and declare our mutations inputs
  • j

    Julien Goux

    02/15/2021, 1:50 PM
    Would it be possible to build the second notation by composing Nexus constructs?
  • j

    Julien Goux

    02/15/2021, 1:52 PM
    I basically wants a single arg of name “input”, with its name derived from the mutation’s name
    ${capitalize(mutationName)}Input
  • b

    blocka

    02/15/2021, 1:59 PM
    is there a way to generate the nexus types without running the server?
    r
    j
    • 3
    • 2
  • d

    DavidT

    02/17/2021, 6:46 PM
    Does anyone have an example of using multiple nexus schemas? I am trying to write a build script for my project with different endpoints (admin, api) with different schemas. But the nexus types are in the global namespace there is names conflicting.
    • 1
    • 1
  • d

    Daniell

    02/22/2021, 9:00 AM
    What would be the nicest way to expose shop locations and shops included in nexus (one to many)? I am using nexus plugin prisma
  • d

    Daniell

    02/22/2021, 9:08 AM
    Ah have to model a new objecttype
    r
    • 2
    • 1
  • c

    Chris

    02/23/2021, 12:38 AM
    I'm trying to implement a node/nodes query for all my Node types, and don't have any way to identify models by their ID (using
    cuid()
    ). Is there any examples that implements this with Prisma, and if not how would I be able to somehow add this metadata to the ID, so that I can avoid having to query all tables.
  • l

    Lars-Jørgen Kristiansen

    02/23/2021, 7:48 AM
    Can nexus generate correct nullability on my resolvers args / return type?
    Copy code
    const Query = queryType({
      definition(t) {
        t.field("lower", {
          type: nonNull("String"),
          args: { name: "String" },
          resolve: (_root, { name }) => name.toLowerCase(),
        });
      },
    });
    Can it protect me from doing this? It should be able to figure out that name can be optional..
    r
    • 2
    • 3
  • h

    Hafffe

    02/23/2021, 6:18 PM
    I trying to understand why one of my two string fields are expecting two arguments, but the other is not.
    Copy code
    export const ContactTag = objectType({
    	name: 'ContactTag',
    	definition(t) {
    		t.int('id');
    		t.string('label');
    		t.string('color');
    	}
    });
    
    // Error
    t.string('color');
    Expected 2 arguments, but got 1.ts(2554)
    definitionBlocks.d.ts(473, 55): Arguments for the rest parameter 'config' were not provided.
    both label and color are just two optional strings in my prisma schema. And I can't understand why they differ.. any tips are welcome 🙂
    r
    • 2
    • 1
  • m

    Meiri Anto

    02/24/2021, 3:00 AM
    does graphql nexus or graphql shield allow for object level authorization?
  • m

    Meiri Anto

    02/24/2021, 3:01 AM
    like no matter which top level query or mutation ends up getting connected to my model
    Customer
    through relations, the same rule will be enforced?
    r
    • 2
    • 1
  • v

    Victor

    02/25/2021, 2:18 AM
    Issue with sourceTypes on latest version
    2.17
    👋 Hey guys, after updating to the latest version of Prisma I have found that the generated types from
    nexus
    and
    makeSchema
    contains an error when using `sourceTypes` to configure backing types, see the code below I use to do so.
    Copy code
    sourceTypes: {
      modules: [
        {
          module: require.resolve('.prisma/client/index.d.ts'),
          alias: 'Prisma',
        },
      ],
    },
    However, when doing this the generated types has a type error, related to
    Prisma.SortOrder
    , see below.
    Copy code
    export interface NexusGenEnums {
      SortOrder: Prisma.SortOrder // <-- this is the error, see below
    }
    
    // Namespace '<ROOT>/node_modules/.prisma/client/index"' has no exported member 'SortOrder'
    I can fix this by manually changing it to this:
    Copy code
    export interface NexusGenEnums {
      SortOrder: Prisma.Prisma.SortOrder // <-- this fixes it
    }
    The underlying issue seems to be that in the latest version of Prisma, SortOrder is no longer exported at the top level. It is exported under the namespace Prisma. Comparing
    2.17
    v.s
    2.13
    below. 2.17 -
    node_modules/.prisma/client/index.d.ts
    Copy code
    export namespace Prisma {
    
      // ... a lot of stuff here
    
      export const SortOrder: {
        asc: 'asc',
        desc: 'desc'
      };
    
      export type SortOrder = (typeof SortOrder)[keyof typeof SortOrder]
    }
    2.13 -
    node_modules/.prisma/client/index.d.ts
    Copy code
    // ..same as above, but also exports type SortOrder, mentioning that it is deprecated
    
    /**
     * @deprecated Renamed to `Prisma.SortOrder`
     */
    export type SortOrder = Prisma.SortOrder
    s
    • 2
    • 4
  • j

    Jonathan

    02/26/2021, 12:09 PM
    Hi folks, does anyone have a favourite tool for generating nice documentation pages for their graphql API? I'm considering something like https://github.com/wayfair/dociql, but I want to look around to see if anyone has other tools they can recommend
  • j

    Julien Goux

    02/26/2021, 10:02 PM
    Still interested by this https://prisma.slack.com/archives/CM2LEN7JL/p1613396982144100 if anyone have an idea 🙂
  • m

    maxweld

    03/01/2021, 9:32 AM
    Hi - I am having problems getting the nexus-prisma tutorial to run correctly. Some advice would be appreciated. 1. I built it following the tutorial pages on the website. All works fine until the last page, testing with Prisma. The app works fine too, and I can write and update the posts in the database. Note that I switched to use a MySQL DB, but that is fine. What is failing is the Test Harness. Even here it builds the DB in MySQL, so the connection is fine. The issue seems to be with the GraphQLClient. 2. Assuming it was me I then downloaded the tutorial from GitHub. I had to play around a bit to get it working, but m now getting the same issue. 3. Here is the output.
    Copy code
    $ npm run test
    
    > workshop@1.0.0 test C:\Users\david\Documents\My-Computing-Projects\Prisma-GraphQL-TS-Auth\workshop
    > npm run generate && jest
    
    
    > workshop@1.0.0 generate C:\Users\david\Documents\My-Computing-Projects\Prisma-GraphQL-TS-Auth\workshop
    > ts-node --transpile-only api/schema
    
     FAIL  tests/Post.test.ts (18.357 s)
      × ensures that a draft can be created and published (12658 ms)
    
      ● ensures that a draft can be created and published
    
        assert.fail(received, expected)
    
        Message:
          unknown message code: 4a
    
          at Parser.handlePacket (node_modules/pg-protocol/src/parser.ts:198:16)
          at Parser.parse (node_modules/pg-protocol/src/parser.ts:101:30)
          at Socket.<anonymous> (node_modules/pg-protocol/src/index.ts:7:48)
    
    Test Suites: 1 failed, 1 total
    Tests:       1 failed, 1 total
    Snapshots:   2 passed, 2 total
    Time:        18.535 s
    Ran all test suites.
    (node:136420) UnhandledPromiseRejectionWarning: Error: Caught error after test environment was torn down
    
    Connection terminated unexpectedly
    (Use `node --trace-warnings ...` to show where the warning was created)
    (node:136420) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see <https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode>). (rejection id: 1)
    (node:136420) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
    npm ERR! code ELIFECYCLE
    npm ERR! errno 1
    npm ERR! workshop@1.0.0 test: `npm run generate && jest`
    npm ERR! Exit status 1
    npm ERR!
    npm ERR! Failed at the workshop@1.0.0 test script.
    npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
    
    npm ERR! A complete log of this run can be found in:
    npm ERR!     C:\Users\david\AppData\Roaming\npm-cache\_logs\2021-02-28T10_07_48_829Z-debug.log
    Any ideas are appreciated. Thanks Secondary issue Also I found the Github repository to be in a bit of a confusing state.: a) Two .env files. The one in the root directory is not used, the one in the /prisma directory is. b) There is a file in the /tests directory which I cannot find referenced in either the code or the tutorial (nexus-test-environment.js). It can probably be removed. c) In the /api/graphql/Posts.ts file there are a number of Interfaces/objectTypes which are not used (Media, Movie, Song). It does not add to the confidence in the tutorial or solution when you find these artefacts.
    r
    a
    • 3
    • 8
  • m

    Meiri Anto

    03/03/2021, 3:10 AM
    why is there a mismatch in allowed types between generated Prisma and Nexus types, especially for Update models? It's really annoying to wrap every field for an update mutation in a
    {set: value}
    For example, in Prisma a model's
    UpdateInput
    type for a given string field is a union type:
    Copy code
    fullName?: NullableStringFieldUpdateOperationsInput | string | null
    but the Nexus-Prisma's generated graphql type has the field type restricted to
    Copy code
    fullName: NullableStringFieldUpdateOperationsInput
    w
    l
    • 3
    • 4
  • j

    Julien Goux

    03/04/2021, 5:06 PM
    Hello, as nexus is probably using this mecanism
  • j

    Julien Goux

    03/04/2021, 5:07 PM
    Does anyone know how to force VSCode to reload a specific .d.ts file ? We use it as module augmentation for i18next, and I’d like VSCode to reload its internal typescript cache when I make some changes in other files
    h
    r
    • 3
    • 4
  • m

    Max Streitberger

    03/07/2021, 9:22 AM
    Hi everyone 🙂 I’m trying to test a mutation where only the user who created an event can modify it. I followed the nexus tutorial to set up the test environment, and the test looks like following:
    Copy code
    it("ensures that only the host can modify an event", async () => {
      await createTestUser(ctx, "Test", "User", "<mailto:test@test.com|test@test.com>", "mySecretPassword")
      const event = await createTestEvent(ctx, event_data.title, event_data.description, when, address)
      console.log(ctx.client)
    
      ctx.client.setHeader("authorization", "")
    
      await createTestUser(ctx, "Test2", "User2", "<mailto:test@test2.com|test@test2.com>", "mySecretPassword2")
      console.log(ctx.client)
    
      async function modifyEvent() {
        const modified_event_response = await ctx.client.request(gql`
          mutation updateDescription($event_id: String!) {
            updateDescription(event_id: $event_id, description: "This is the updated description.") {
              event_id
              description
            }
          }
        `,{ event_id: event.event_id }
        );
    
        return modified_event_response
      }
    
      expect(modifyEvent()).toThrow("Sorry, but you are not allowed to do this")
    })
    But when I try to run this test, I get this error:
    Copy code
    FetchError: request to <http://localhost:4000/> failed, reason: connect ECONNREFUSED 127.0.0.1:4000
    Does someone have an idea of how to solve this?
  • m

    Mikastark

    03/10/2021, 10:58 AM
    Hi everyone 🙂 I want to try the early
    nexus-prisma
    plugin (0.24.0-next.1) but when I want to generate (
    npx prisma generate
    ) I get this error "`nexus-prisma` is no longer a generator. You can read more at https://pris.ly/nexus-prisma-upgrade-0.4". What I'm doing wrong ? package.json (partial)
    Copy code
    "dependencies": {
        "@prisma/client": "~2.17.0",
        "graphql": "^15.5.0",
        "nexus": "^1.0.0",
        "nexus-prisma": "^0.24.0-next.1"
      },
    "devDependencies": {
        "prisma": "~2.17.0",
        "typescript": "^4.2.3"
      },
    prisma/schema.prisma
    Copy code
    generator client {
      provider = "prisma-client-js"
    }
    
    generator nexusPrisma {
      provider = "nexus-prisma"
    }
    r
    • 2
    • 10
  • m

    Mark

    03/10/2021, 2:31 PM
    Hi! Wondering if anyone has tried running a server with two separate nexus schemas at two separate endpoints. Meaning:
    Copy code
    const app = express();
    const server = new ApolloServer({
      schema: schema,
      context: createContext,
    })
    const adminServer = new ApolloServer({
      schema: adminSchema,
      context: createContext,
    })
    
    server.applyMiddleware({ app, path: '/graphql', cors: true });
    adminServer.applyMiddleware({ app, path: '/admin', cors: true });
    The issue seems to be that the Typescript compilation fails because the Nexus generated types exist in two separate places, and there are overlaps. Does anyone know if this has any chance of working, and if so, how should I manage it?
    r
    • 2
    • 2
  • d

    Daniell

    03/11/2021, 1:49 PM
    Do you have any insight if the new version of nexus will support something similar to what typegraphql has? Like generating all possible queries, I think it's a pretty nice feature to create client screens easily
    r
    • 2
    • 1
  • p

    Philipp Humburg

    03/11/2021, 7:11 PM
    Hey guys, is there a way to do Integration testing which can run concurrently like with jest? And maybe has an example repo?
    r
    • 2
    • 1
  • d

    Dregond

    03/14/2021, 6:02 AM
    Hey All, Trying to get the Relay Pagination going with nexus and prisma (without the plugin) i found this plugin https://nexusjs.org/docs/plugins/connection but i honestly can't understand from the docs how to use it
  • b

    Ben Walker

    03/14/2021, 10:08 PM
    Has anyone had any luck with filtering subscriptions in nexus? I’m using mercurius/fastify as the server, and I can get subscriptions themselves working with nexus and the mercurius pubsub object on the context, but I don’t see a good way to filter the subscriptions payloads to the consumers that care about them 🤔
    • 1
    • 1
  • d

    Daniell

    03/15/2021, 9:11 AM
    Should I use the "in" operator here? Typescript complains that message does not exists on type User
    h
    • 2
    • 1
  • d

    Dregond

    03/16/2021, 4:57 AM
    anyone familiar with connectionField ?
  • j

    Julien Goux

    03/17/2021, 10:12 AM
    @Ryan any advice on this? https://prisma.slack.com/archives/CM2LEN7JL/p1613396982144100
1...181920...25Latest