keystone: Underscore in field name causes GraphQL error: Unable to find Mongo field which maps to graphQL path error

Bug report

Describe the bug

I’m migrating from Keystone 4 to Keystone 5. I have a database that has fields which have underscores in them (news_site, news_site_long). When I define these fields in createList I get the following error:

GraphQL error: Unable to find Mongo field which maps to graphQL path news

I’ve been searching in the docs to prevent this behavior, but I couldn’t find an option.

To Reproduce

Steps to reproduce the behaviour. Please provide code snippets or a repository:

  1. Define a field with an underscore in it
  2. In the admin GUI, Click on the list
  3. See error

Expected behaviour

I expect to see a list of all my entries in that MongoDB collection.

Screenshots

image

System information

  • OS: Debian, MacOS
  • Browser (if applies): Opera, Chrome

Additional context

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 1
  • Comments: 20 (5 by maintainers)

Most upvoted comments

By accident, I found a possible solution/workaround: Define a non-underscore item as first item in the list (title, name, etc.). All underscore items will now behave correctly.

Facing similar issue.

Solution : change the item names to camelCase (for Mongo Users)

In case you are using Knex Adapter with postgreSQL, change the item names to all lowercase or uppercase, depending upon column names in your DB.

That worked partially for me, as defaultSort: breaks it again.

Unfortunately, with defaultSort: it breaks again when you try to sort on an item with an underscore.