i'm wondering if i can, with little code, have nex...
# orm-help
i
i'm wondering if i can, with little code, have nexus-prisma forward all the CRUD of an entity as is except a predefined argument. one of my fields is the request domain, can't have it coming from the client. any pointers appreciated.
s
If I understand what you are doing, I think you can achieve this by passing a function to the filter option of
t.prismaFields
https://github.com/prisma/nexus-prisma#signature
Copy code
definition(t) {
    t.prismaFields({
      filter: fields => fields.filter(x => x === "domain")
    });
i
i need to mask a field argument on the mutations, isn't this just about returned fields?
s
yeah correct. wan’t sure exactly what you mean. that code won’t help you in that case
i
thank you anyway
it seems like a pretty useful thing for multi-tenant scenarios where the data-model takes care of tenancy
s
Yeah, the only way I can see would require explicitly listing out all the fields you want to expose. And then for the field you want to remove an argument on, still listing out all the arguments you want to keep. At least if you do that, vs-code should help you with autocomplete… Expose only the users field, and only the first and last args
Copy code
const Query = prismaObjectType({
  name: 'Query',
  definition(t) {
    t.prismaFields([{ name: 'users', args: ['first', 'last'] }])
  },
})
Actually, if you look at https://github.com/prisma/nexus-prisma#tprismatype maybe you could do something like
Copy code
const newArgs = {{
        ...t.prismaType.users.args,
      }}
delete newArgs.requestDomain;

t.field('users', {
      ...t.prismaType.users,
      args: newArgs,
      resolve(root, args, ctx) {
        // Custom implementation
      },
    })
i
that'll work, was just wondering how much boilerplate i'd need. i have a bunch of entities relying on the domain.. thank you again
imho i think easing this kind of thing should take priority to an integrated auth.