question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
derkweijerscommented, Dec 2, 2019

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.

1reaction
derkweijerscommented, Jan 14, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to resolve mongodb embedded document array of object ...
My Graphql query is working now as below. query{ feeds { id feedname feedtime feeditems { farmintakes { id name remarks } id...
Read more >
GraphQL Types, Resolvers, and Operators - MongoDB
If the field name is not defined for the document at all, or if the value is explicitly set to null , then...
Read more >
How To Set Up a Ruby on Rails GraphQL API - DigitalOcean
In this tutorial, you will build a GraphQL-powered Ruby on Rails ... by appending an underscore ( _ ) followed by the environment...
Read more >
typescript-operations - GraphQL Code Generator
Without loading your GraphQL operations ( query , mutation , subscription and fragment ), you won't see any change in the generated output....
Read more >
Prisma schema API (Reference)
Name, Required, Type, Description. provider, Yes, String ( postgresql , mysql , sqlite , sqlserver , mongodb , cockroachdb ), Describes which data...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found