Nexus-plugin-prisma: Prisma2 ordering property doesn't work on models

Created on 21 Aug 2019  路  5Comments  路  Source: graphql-nexus/nexus-plugin-prisma

Steps

On adding the ordering property to the model, the compiler throws an error

import { objectType } from '@prisma/nexus'

export const User = objectType({
  name: 'User',
  definition(t) {
    t.model.id()
    t.model.name()
    t.model.email()
    t.model.posts({
      ordering: true,
    })
  },
})

The following error is received in the terminal

Using ts-node version 8.3.0, typescript version 3.5.3
Error: Could not find ordering argument for User.posts

Even the internal ordering fields are also not working

import { objectType } from '@prisma/nexus'

export const User = objectType({
  name: 'User',
  definition(t) {
    t.model.id()
    t.model.name()
    t.model.email()
    t.model.posts({
      ordering: { title: true },
    })
  },
})

Library versions

prisma2: 2.0.0-preview-7
@prisma/nexus: 0.0.1
nexus: 0.12.0-beta.6

notinvalid typbug

Most helpful comment

I'm having the same issue.

Steps

I started my project using prisma2 init and choosing SQLite, TypeScript, and the GraphQL boilerplate. I simply edited src/resolvers/User.ts by changing one line of code:

...
  t.model.posts({ pagination: false });
  <CHANGED TO>
  t.model.posts({ pagination: false, filtering: true, ordering: true });
...

When I start the server I get the error Error: Could not find filtering argument for User.posts. Both filtering and ordering throw an error even if used independently.

Library versions

prisma2: 2.0.0-preview-8
@prisma/nexus: 0.0.1
nexus: 0.12.0-beta.6

All 5 comments

I'm having the same issue.

Steps

I started my project using prisma2 init and choosing SQLite, TypeScript, and the GraphQL boilerplate. I simply edited src/resolvers/User.ts by changing one line of code:

...
  t.model.posts({ pagination: false });
  <CHANGED TO>
  t.model.posts({ pagination: false, filtering: true, ordering: true });
...

When I start the server I get the error Error: Could not find filtering argument for User.posts. Both filtering and ordering throw an error even if used independently.

Library versions

prisma2: 2.0.0-preview-8
@prisma/nexus: 0.0.1
nexus: 0.12.0-beta.6

You might have more luck opening this under this project: https://github.com/prisma/nexus-prisma - I believe the issue is specific to the nexus-prisma plugin.

Can you please update your deps to the latest versions. You can refer to the example in this repo.

You can see a working example of ordering in the example. Just update to latest versions to get things working.

@jasonkuhrt Thanks for the guidance, looks like examples/boilerplate must have been incorrect. I've switched to using nexus rather than @prisma/nexus and followed the example, can confirm filtering/order is working.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

colinhacks picture colinhacks  路  5Comments

lterfloth picture lterfloth  路  5Comments

jamesopti picture jamesopti  路  4Comments

antonbramsen picture antonbramsen  路  4Comments

sachaw picture sachaw  路  3Comments