Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CustomField inconsistent knex/mongoose logic #3207

Closed
pahaz opened this issue Jun 27, 2020 · 1 comment
Closed

CustomField inconsistent knex/mongoose logic #3207

pahaz opened this issue Jun 27, 2020 · 1 comment

Comments

@pahaz
Copy link
Contributor

pahaz commented Jun 27, 2020

Bug report

Describe the bug

I have an Options field based on the MuliCheck field example. Options field source

I have a User list like so:

const { Stars, Options } = require('../custom-fields')
...

keystone.createList('User', {
    ...
    fields: {
        settings: { type: Options, options: ['Feature1', 'Feature2'] },
        ...
    }
})

I have a test which filters the User list by settings field. source

At the moment this test work as expected for knex.
mongoose fail by an error:

    [
      {
        message: "'User' Mongo List Adapter failed to determine field responsible for the query condition 'settings'. 'settings' was seen by following the query 'settings'.",
        locations: [ { line: 2, column: 3 } ],
        path: [ 'users' ],
        extensions: { code: 'INTERNAL_SERVER_ERROR' },
        uid: 'ckbxrvoxy0000e55l4i2aecuk',
        name: 'GraphQLError'
      }
    ]

Traceback:

"Error: 'User' Mongo List Adapter failed to determine field responsible for the query condition 'settings'. 'settings' was seen by following the query 'settings'.
    at getRelatedListAdapterFromQueryPath (/nodejs-hackathon-boilerplate-starter-kit/node_modules/@keystonejs/mongo-join-builder/lib/tokenizers.js:31:13)
    at simpleTokenizer (/nodejs-hackathon-boilerplate-starter-kit/node_modules/@keystonejs/mongo-join-builder/lib/tokenizers.js:98:26)
    at /nodejs-hackathon-boilerplate-starter-kit/node_modules/@keystonejs/mongo-join-builder/lib/query-parser.js:55:27
    at Array.map (<anonymous>)
    at queryParser (/nodejs-hackathon-boilerplate-starter-kit/node_modules/@keystonejs/mongo-join-builder/lib/query-parser.js:27:47)
    at /nodejs-hackathon-boilerplate-starter-kit/node_modules/@keystonejs/mongo-join-builder/lib/query-parser.js:51:48
    at Array.map (<anonymous>)
    at queryParser (/nodejs-hackathon-boilerplate-starter-kit/node_modules/@keystonejs/mongo-join-builder/lib/query-parser.js:27:47)
    at MongooseListAdapter._itemsQuery (/nodejs-hackathon-boilerplate-starter-kit/node_modules/@keystonejs/adapter-mongoose/lib/adapter-mongoose.js:553:23)
    at MongooseListAdapter.itemsQuery (/nodejs-hackathon-boilerplate-starter-kit/node_modules/@keystonejs/keystone/lib/adapters/index.js:139:32)
    at List._itemsQuery (/nodejs-hackathon-boilerplate-starter-kit/node_modules/@keystonejs/keystone/lib/ListTypes/list.js:670:40)
    at List.listQuery (/nodejs-hackathon-boilerplate-starter-kit/node_modules/@keystonejs/keystone/lib/ListTypes/list.js:584:17)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)

At the moment the problem is inside mongo-join-builder/lib/query-parser.js:queryParse:44 code:

image

The queryParse logic doesn't expect custom query objects.

The key

The key difference between knex-adapter and mongoose-adapter is the knex-adapter uses listAdapter.fieldAdaptersByPath here
which desn't used by mongoose-adapter here

additional

I think it's probably the same problem inside the File field. If anyone tries to filter by file field on Mongo. (I don't test it yet)

@pahaz pahaz changed the title CustomField inconsistent knex/mongoose CustomField inconsistent knex/mongoose logic Jun 27, 2020
@bladey
Copy link
Contributor

bladey commented Apr 8, 2021

Keystone 5 has officially moved into active maintenance mode as we push towards the next major new version Keystone Next, you can find out more information about this transition here.

In an effort to sustain the project going forward, we're cleaning up and closing old issues such as this one. If you feel this issue is still relevant for Keystone Next, please let us know.

@bladey bladey closed this as completed Apr 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants