paljs / prisma-tools

Prisma tools to help you generate CRUD system for GraphQL servers
https://paljs.com
MIT License
680 stars 55 forks source link

PrismaSelect "Cannot convert undefined or null to object" on custom scalar field #246

Open nazarii-marko opened 2 years ago

nazarii-marko commented 2 years ago

It seems there's an issue in filterBy() while processing the custom scalar. Graphql schema:

scalar LocalizedString

type Product {
  id: String
  name: LocalizedString
}

type Query {
  product: Product 
}

schema.prisma:

model Product {
  ...
  name  LocalizedString
}
model LocalizedString {
  ...
  language  String
  value        String
}

scalar resolver:

new GraphQLScalarType({
    name: 'LocalizedString',
    serialize: (localizedString) => {
        return localizedString.value;
    },
    parseValue: ({ language, value }) => {
        return {
            language,
            value,
        };
    },
});

The error is thrown on new PrismaSelect(info).value and I managed to track it down to filterBy method, specifically this check: Object.keys(subModelFilter.select).length > 0. The issue is that field.kind returns object, whereas subModelFilter is of type Boolean