diff --git a/.changeset/popular-goats-juggle.md b/.changeset/popular-goats-juggle.md new file mode 100644 index 00000000000..71215b9ee05 --- /dev/null +++ b/.changeset/popular-goats-juggle.md @@ -0,0 +1,5 @@ +--- +'@keystone-next/keystone': patch +--- + +Fixed a bug in `context.db.lists` API when finding items that don't exist. diff --git a/packages/keystone/src/lib/context/executeGraphQLFieldToRootVal.ts b/packages/keystone/src/lib/context/executeGraphQLFieldToRootVal.ts index 5c35e6ac33f..9e392c62e02 100644 --- a/packages/keystone/src/lib/context/executeGraphQLFieldToRootVal.ts +++ b/packages/keystone/src/lib/context/executeGraphQLFieldToRootVal.ts @@ -134,8 +134,8 @@ function getRootValGivenOutputType(originalType: OutputType, value: any): any { if (originalType instanceof GraphQLNonNull) { return getRootValGivenOutputType(originalType.ofType, value); } + if (value === null) return null; if (originalType instanceof GraphQLList) { - if (value === null) return null; return value.map((x: any) => getRootValGivenOutputType(originalType.ofType, x)); } return value[rawField];