nexus icon indicating copy to clipboard operation
nexus copied to clipboard

Only pass relational data included in

Open JonasRothmann opened this issue 3 years ago • 0 comments

I have an objectType Customer, which has an ID and one-to-many relationship with Visits, the problem I am having is that I can't limit which visits are shown through the query.

I am using prisma-nexus but since this is just relating to graphql-nexus the code isn't what I use but shows the issue.

    t.nullable.field('customer', {
      type: "Customer",
      args: {
        id: nonNull(intArg())
      },
      resolve: async (_parent, args, context: Context) => {
        return { id: args.id, visits: [{ id: 1 }, { id: 2 }] }
      },
    })

I basically want Nexus to only show the visits that are passed through the query, regardless of the objectType resolver, is this possible? Right now it returns all visits.

JonasRothmann avatar Sep 03 '21 10:09 JonasRothmann