Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate WhereInput type and use outside of crud #1008

Open
thehappycoder opened this issue Dec 24, 2020 · 3 comments
Open

Generate WhereInput type and use outside of crud #1008

thehappycoder opened this issue Dec 24, 2020 · 3 comments

Comments

@thehappycoder
Copy link

thehappycoder commented Dec 24, 2020

Is it possible in 2020? I remember that wasn't possible the last time I tried nexus.

I've found nestjs-query that is able to generate such types and used them in custom queries. Would be awesome if nexus could do that as well.

@Fi1osof
Copy link

Fi1osof commented Feb 22, 2021

Still waiting for...

@royletron
Copy link

royletron commented Feb 11, 2022

It's amazingly already in there, at least I think it is, assuming you want to do something like this:

import {arg} from 'nexus'
t.int("numberOfFibbles", {
  args: {
    where: arg({ type: "FibbleWhereInput"})
  },
  async resolve(source, args, context) {
    const count = await context.prisma.fibble.count({where: args.where});
    return count;
  }
})

It seems arg({ type: "FibbleWhereInput"}) will give you access to any type currently in your schema

@Fi1osof
Copy link

Fi1osof commented Feb 12, 2022

will give you access to any type currently in your schema

Will, if FibbleWhereInput already registred. It will be only if you call before some like t.crud.fibbles(). This will generate FibbleWhereInput and yes, now you can use it like you said.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants