keystone icon indicating copy to clipboard operation
keystone copied to clipboard

Admin UI not working as expected for extended / merged list schema

Open JoinThisBand opened this issue 3 months ago • 1 comments

I have two lists, Product and ProductRange. There is a many-to-one relationship between these lists, so each Product is linked to a single ProductRange. This means that I have a field called productRangeId in the Prisma model for Product.

I want to use this field to sort any queries for multiple products, so products from the same range are grouped together. I'm attempting to do this by extending my schema as shown in the docs. My code is below.

export function extendGraphqlSchema(baseSchema: GraphQLSchema) {
  return mergeSchemas({
    schemas: [baseSchema],
    typeDefs: `
    type Query {
      products(where: ProductWhereInput): [Product]!
    }`,
    resolvers: {
      Query: {
        products: (root, { where, orderBy, skip, take }, context: Context, info: GraphQLResolveInfo) => {
          return context.prisma.product.findMany({ orderBy: { 'productRangeId': 'asc' }, skip, take, where });
        },
      }
    },
  })
}

This works as expected in the API explorer, but no products are listed in the admin UI - see screengrabs.

However if I remove the where param from the findMany query (see below) it seems to fix the issue in admin.

...
    products: (root, { where, orderBy, skip, take }, context: Context, info: GraphQLResolveInfo) => {
      return context.prisma.product.findMany({ orderBy: { 'productRangeId': 'asc' }, skip, take });
    },
...

For requests from admin the where query is { OR: [] }. Obviously this isn't really doing anything and could be tested for and removed, but wanted to ask whether there an issue with my approach, or is this a bug?

Keystone Admin API Explorer

Node is v24.7.0 @keystone-6/core is 6.5.1 Browser is Safari

Thanks for you efforts building Keystone - it's great!!

JoinThisBand avatar Sep 23 '25 08:09 JoinThisBand

May I work on this ?

sudam802 avatar Nov 29 '25 11:11 sudam802